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
-
#-(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 StateMachines::Matcher
Instance Method Details
#-(blacklist) ⇒ Object
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
33 34 35 |
# File 'lib/state_machines/matcher.rb', line 33 def -(blacklist) BlacklistMatcher.new(blacklist) end |
#description ⇒ Object
A human-readable description of this matcher. Always “all”.
48 49 50 |
# File 'lib/state_machines/matcher.rb', line 48 def description 'all' end |
#filter(values) ⇒ Object
Always returns the given set of values
43 44 45 |
# File 'lib/state_machines/matcher.rb', line 43 def filter(values) values end |
#matches?(value, context = {}) ⇒ Boolean
Always returns true
38 39 40 |
# File 'lib/state_machines/matcher.rb', line 38 def matches?(value, context = {}) true end |