Class: StateMachines::AllMatcher

Inherits:
Matcher
  • Object
show all
Includes:
Singleton
Defined in:
lib/state_machines/matcher.rb

Overview

Matches any given value. Since there is no configuration for this type of matcher, it must be used as a singleton.

Instance Attribute Summary

Attributes inherited from Matcher

#values

Instance Method Summary collapse

Methods inherited from Matcher

#initialize

Constructor Details

This class inherits a constructor from StateMachines::Matcher

Instance Method Details

#-(other) ⇒ Object Also known as: except

Generates a blacklist matcher based on the given set of values

Examples

matcher = StateMachines::AllMatcher.instance - [:parked, :idling]
matcher.matches?(:parked)       # => false
matcher.matches?(:first_gear)   # => true


35
36
37
# File 'lib/state_machines/matcher.rb', line 35

def -(other)
  BlacklistMatcher.new(other)
end

#descriptionObject

A human-readable description of this matcher. Always “all”.



51
52
53
# File 'lib/state_machines/matcher.rb', line 51

def description
  'all'
end

#filter(values) ⇒ Object

Always returns the given set of values



46
47
48
# File 'lib/state_machines/matcher.rb', line 46

def filter(values)
  values
end

#matches?(_value, _context = {}) ⇒ Boolean

Always returns true

Returns:

  • (Boolean)


41
42
43
# File 'lib/state_machines/matcher.rb', line 41

def matches?(_value, _context = {})
  true
end