Class: StateMachines::AllMatcher

Inherits:
Matcher
  • Object
show all
Includes:
Singleton
Defined in:
lib/state_machines/matcher.rb

Overview

Matches any given value. 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

#initialize

Constructor Details

This class inherits a constructor from StateMachines::Matcher

Instance Method Details

#-(blacklist) ⇒ Object

Generates a blacklist matcher based on the given set of values

Examples

matcher = StateMachines::AllMatcher.instance - [:parked, :idling]
matcher.matches?(:parked)       # => false
matcher.matches?(:first_gear)   # => true


33
34
35
# File 'lib/state_machines/matcher.rb', line 33

def -(blacklist)
  BlacklistMatcher.new(blacklist)
end

#descriptionObject

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



48
49
50
# File 'lib/state_machines/matcher.rb', line 48

def description
  'all'
end

#filter(values) ⇒ Object

Always returns the given set of values



43
44
45
# File 'lib/state_machines/matcher.rb', line 43

def filter(values)
  values
end

#matches?(value, context = {}) ⇒ Boolean

Always returns true

Returns:

  • (Boolean)


38
39
40
# File 'lib/state_machines/matcher.rb', line 38

def matches?(value, context = {})
  true
end