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”.
| 120 121 122 | # File 'lib/state_machines/matcher.rb', line 120 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
| 115 116 117 | # File 'lib/state_machines/matcher.rb', line 115 def matches?(value, context) context[:from] == value end |