Class: StateMachine::AllMatcher
- Includes:
- Singleton
- Defined in:
- lib/state_machine/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
-
#-(blacklist) ⇒ Object
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 StateMachine::Matcher
Instance Method Details
#-(blacklist) ⇒ Object
Generates a blacklist matcher based on the given set of values
Examples
matcher = StateMachine::AllMatcher.instance - [:parked, :idling]
matcher.matches?(:parked) # => false
matcher.matches?(:first_gear) # => true
35 36 37 |
# File 'lib/state_machine/matcher.rb', line 35 def -(blacklist) BlacklistMatcher.new(blacklist) end |
#description ⇒ Object
A human-readable description of this matcher. Always “all”.
50 51 52 |
# File 'lib/state_machine/matcher.rb', line 50 def description 'all' end |
#filter(values) ⇒ Object
Always returns the given set of values
45 46 47 |
# File 'lib/state_machine/matcher.rb', line 45 def filter(values) values end |
#matches?(value, context = {}) ⇒ Boolean
Always returns true
40 41 42 |
# File 'lib/state_machine/matcher.rb', line 40 def matches?(value, context = {}) true end |