Class: StateMachines::AllMatcher
- 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
Instance Method Summary collapse
-
#-(other) ⇒ Object
(also: #except)
Generates a blacklist matcher based on the given set of values.
-
#description ⇒ Object
A human-readable description of this matcher.
-
#filter(values) ⇒ Object
Always returns the given set of values.
-
#matches?(_value, _context = {}) ⇒ Boolean
Always returns true.
Methods inherited from Matcher
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 |
#description ⇒ Object
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
41 42 43 |
# File 'lib/state_machines/matcher.rb', line 41 def matches?(_value, _context = {}) true end |