Class: StateMachine::AllMatcher

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

Instance Method Details

- (Object) -(blacklist)

Generates a blacklist matcher based on the given set of values

Examples

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


35
36
37
# File 'lib/state_machine/matcher.rb', line 35

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

- (Object) description

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



50
51
52
# File 'lib/state_machine/matcher.rb', line 50

def description
  'all'
end

- (Object) filter(values)

Always returns the given set of values



45
46
47
# File 'lib/state_machine/matcher.rb', line 45

def filter(values)
  values
end

- (Boolean) matches?(value, context = {})

Always returns true



40
41
42
# File 'lib/state_machine/matcher.rb', line 40

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