Exception: SplitIoClient::CombiningMatcher
- Inherits:
-
NoMethodError
- Object
- NoMethodError
- SplitIoClient::CombiningMatcher
- Defined in:
- lib/engine/matchers/combining_matcher.rb
Overview
class to implement the combining matcher
Instance Method Summary collapse
-
#and_eval(key, attributes) ⇒ boolean
auxiliary method to evaluate each of the matchers within the combiner.
-
#equals?(obj) ⇒ Boolean
evaluates if the given object equals the matcher.
-
#initialize(combiner, delegates) ⇒ CombiningMatcher
constructor
A new instance of CombiningMatcher.
-
#match?(key, attributes) ⇒ boolean
evaluates if the key matches the matchers within the combiner.
-
#to_s ⇒ Object
function to print string value for this matcher.
Constructor Details
#initialize(combiner, delegates) ⇒ CombiningMatcher
Returns a new instance of CombiningMatcher.
19 20 21 22 23 24 25 26 |
# File 'lib/engine/matchers/combining_matcher.rb', line 19 def initialize(combiner, delegates) unless delegates.nil? @matcher_list = delegates end unless combiner.nil? @combiner = combiner end end |
Instance Method Details
#and_eval(key, attributes) ⇒ boolean
auxiliary method to evaluate each of the matchers within the combiner
54 55 56 57 58 59 60 |
# File 'lib/engine/matchers/combining_matcher.rb', line 54 def and_eval(key, attributes) result = true @matcher_list.each do |delegate| result &= delegate.match? key, attributes end result end |
#equals?(obj) ⇒ Boolean
evaluates if the given object equals the matcher
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/engine/matchers/combining_matcher.rb', line 68 def equals?(obj) if obj.nil? false elsif !obj.instance_of?(CombiningMatcher) false elsif self.equal?(obj) true else false end end |
#match?(key, attributes) ⇒ boolean
evaluates if the key matches the matchers within the combiner
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/engine/matchers/combining_matcher.rb', line 34 def match?(key, attributes) if @matcher_list.empty? return false end case @combiner when Combiners::AND return and_eval(key, attributes) else @logger.error('Invalid combiner type') return false end end |
#to_s ⇒ Object
function to print string value for this matcher
84 85 86 87 88 89 90 91 |
# File 'lib/engine/matchers/combining_matcher.rb', line 84 def to_s result = '' @matcher_list.each_with_index do |matcher, i| result += matcher.to_s result += ' ' + @combiner if i != 0 end result end |