Class: SplitIoClient::NegationMatcher

Inherits:
Matcher
  • Object
show all
Defined in:
lib/splitclient-rb/engine/matchers/negation_matcher.rb

Overview

class to implement the negation of a matcher

Constant Summary collapse

MATCHER_TYPE =
'NEGATION_MATCHER'

Instance Method Summary collapse

Methods inherited from Matcher

#equals?

Constructor Details

#initialize(matcher = nil) ⇒ NegationMatcher

Returns a new instance of NegationMatcher.



10
11
12
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 10

def initialize(matcher = nil)
  @matcher = matcher
end

Instance Method Details

#attribute ⇒ Object



30
31
32
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 30

def attribute
  @matcher.attribute
end

#match?(args) ⇒ boolean

evaluates if the key matches the negation of the matcher

Parameters:

  • key (string) —

    key value to be matched

Returns:

  • (boolean) —

    evaluation of the negation matcher



20
21
22
23
24
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 20

def match?(args)
  matches = !@matcher.match?(args)
  SplitLogger.log_if_debug("[NegationMatcherMatcher] Matcher #{@matcher} Arguments #{args} -> #{matches}")
  matches
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 26

def respond_to?(method)
  @matcher.respond_to? method
end

#string_type? ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 34

def string_type?
  @matcher.string_type?
end

#to_s ⇒ string

function to print string value for this matcher

Returns:

  • (string) —

    string value of this matcher



42
43
44
# File 'lib/splitclient-rb/engine/matchers/negation_matcher.rb', line 42

def to_s
  "not #{@matcher}"
end