Class: StateMachine::LoopbackMatcher
- Includes:
- Singleton
- Defined in:
- lib/state_machine/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 StateMachine::Matcher
Instance Method Details
#description ⇒ Object
A human-readable description of this matcher. Always “same”.
119 120 121 |
# File 'lib/state_machine/matcher.rb', line 119 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 = StateMachine::LoopbackMatcher.instance
matcher.matches?(:parked, :from => :parked) # => true
matcher.matches?(:parked, :from => :idling) # => false
114 115 116 |
# File 'lib/state_machine/matcher.rb', line 114 def matches?(value, context) context[:from] == value end |