Class: StateMachines::Matcher
- Inherits:
-
Object
- Object
- StateMachines::Matcher
- 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.
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
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
#values ⇒ Object (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 |