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.

Direct Known Subclasses

AllMatcher, BlacklistMatcher, LoopbackMatcher, WhitelistMatcher

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Matcher) initialize(values = [])

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

- (Object) values (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

- (Object) filter(values)

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