Class: EnumStateMachine::LoopbackMatcher

Inherits:
Matcher
  • Object
show all
Includes:
Singleton
Defined in:
lib/enum_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

#values

Instance Method Summary collapse

Methods inherited from Matcher

#filter, #initialize

Constructor Details

This class inherits a constructor from EnumStateMachine::Matcher

Instance Method Details

#descriptionObject

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



119
120
121
# File 'lib/enum_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 = EnumStateMachine::LoopbackMatcher.instance
matcher.matches?(:parked, :from => :parked)   # => true
matcher.matches?(:parked, :from => :idling)   # => false

Returns:

  • (Boolean)


114
115
116
# File 'lib/enum_state_machine/matcher.rb', line 114

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