Class: StateMachines::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/state_machines/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



10
11
12
# File 'lib/state_machines/matcher.rb', line 10

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



7
8
9
# File 'lib/state_machines/matcher.rb', line 7

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



16
17
18
# File 'lib/state_machines/matcher.rb', line 16

def filter(values)
  self.values & values
end