lib/splitclient-rb/engine/matchers/negation_matcher.rb in splitclient-rb-4.3.0.canary.2 vs lib/splitclient-rb/engine/matchers/negation_matcher.rb in splitclient-rb-4.3.0
- old
+ new
@@ -1,30 +1,38 @@
module SplitIoClient
-
#
# class to implement the negation of a matcher
#
- class NegationMatcher < NoMethodError
+ class NegationMatcher
+ MATCHER_TYPE = 'NEGATION_MATCHER'.freeze
- @matcher = nil
-
- def initialize(matcher)
- unless matcher.nil?
- @matcher = matcher
- end
+ def initialize(matcher = nil)
+ @matcher = matcher
end
#
# evaluates if the key matches the negation of the matcher
#
# @param key [string] key value to be matched
#
# @return [boolean] evaluation of the negation matcher
- def match?(matching_key, bucketing_key, evaluator, attributes)
- !@matcher.match?(matching_key, bucketing_key, evaluator, attributes)
+ def match?(args)
+ !@matcher.match?(args)
end
+ def respond_to?(method)
+ @matcher.respond_to? method
+ end
+
+ def attribute
+ @matcher.attribute
+ end
+
+ def string_type?
+ @matcher.string_type?
+ end
+
#
# evaluates if the given object equals the matcher
#
# @param obj [object] object to be evaluated
#
@@ -44,11 +52,9 @@
#
# function to print string value for this matcher
#
# @reutrn [string] string value of this matcher
def to_s
- 'not ' + @matcher.to_s
+ "not #{@matcher}"
end
-
end
-
end