Class: StateMachine::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/state_machine/matcher.rb

Overview

Provides a general strategy pattern for determining whether a match is found for a value. The algorithm that actually determines the match depends on the matcher in use.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values = []) ⇒ Matcher

Creates a new matcher for querying against the given set of values



12
13
14
# File 'lib/state_machine/matcher.rb', line 12

def initialize(values = [])
  @values = values.is_a?(Array) ? values : [values] 
end

Instance Attribute Details

#valuesObject (readonly)

The list of values against which queries are matched



9
10
11
# File 'lib/state_machine/matcher.rb', line 9

def values
  @values
end

Instance Method Details

#filter(values) ⇒ Object

Generates a subset of values that exists in both the set of values being filtered and the values configured for the matcher



18
19
20
# File 'lib/state_machine/matcher.rb', line 18

def filter(values)
  self.values & values
end