Class: StateMachines::LoopbackMatcher

Inherits:
Matcher
  • Object
show all
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

#values

Instance Method Summary collapse

Methods inherited from Matcher

#filter, #initialize

Constructor Details

This class inherits a constructor from StateMachines::Matcher

Instance Method Details

#descriptionObject

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

Returns:

  • (Boolean)

112
113
114
# File 'lib/state_machines/matcher.rb', line 112

def matches?(value, context)
  context[:from] == value
end