Class: StateMachine::Matcher
- Inherits:
-
Object
- Object
- StateMachine::Matcher
- 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
-
#values ⇒ Object
readonly
The list of values against which queries are matched.
Instance Method Summary collapse
-
#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.
-
#initialize(values = []) ⇒ Matcher
constructor
Creates a new matcher for querying against the given set of values.
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
#values ⇒ Object (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 |