Class: StateMachines::LoopbackMatcher
- Includes:
- Singleton
- Defined in:
- lib/state_machines/matcher.rb
Overview
Matches a loopback of two values within a context. 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
-
#description ⇒ Object
A human-readable description of this matcher.
-
#matches?(value, context) ⇒ Boolean
Checks whether the given value matches what the value originally was.
Methods inherited from Matcher
Constructor Details
This class inherits a constructor from StateMachines::Matcher
Instance Method Details
#description ⇒ Object
A human-readable description of this matcher. Always “same”.
117 118 119 |
# File 'lib/state_machines/matcher.rb', line 117 def description 'same' end |
#matches?(value, context) ⇒ Boolean
Checks whether the given value matches what the value originally was. This value should be defined in the context.
Examples
matcher = StateMachines::LoopbackMatcher.instance
matcher.matches?(:parked, :from => :parked) # => true
matcher.matches?(:parked, :from => :idling) # => false
112 113 114 |
# File 'lib/state_machines/matcher.rb', line 112 def matches?(value, context) context[:from] == value end |