class StateMachine::LoopbackMatcher

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.

Public Instance Methods

description() click to toggle source

A human-readable description of this matcher. Always “same”.

    # File lib/state_machine/matcher.rb
119 def description
120   'same'
121 end
matches?(value, context) click to toggle source

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
    # File lib/state_machine/matcher.rb
114 def matches?(value, context)
115   context[:from] == value
116 end