Exception: SplitIoClient::NegationMatcher

Inherits:
NoMethodError
  • Object
show all
Defined in:
lib/engine/matchers/negation_matcher.rb

Overview

class to implement the negation of a matcher

Instance Method Summary collapse

Constructor Details

#initialize(matcher) ⇒ NegationMatcher

Returns a new instance of NegationMatcher.



10
11
12
13
14
# File 'lib/engine/matchers/negation_matcher.rb', line 10

def initialize(matcher)
  unless matcher.nil?
    @matcher = matcher
  end
end

Instance Method Details

#equals?(obj) ⇒ Boolean

evaluates if the given object equals the matcher

Parameters:

  • obj (object)

    object to be evaluated

Returns:

  • (Boolean)


32
33
34
35
36
37
38
39
40
41
42
# File 'lib/engine/matchers/negation_matcher.rb', line 32

def equals?(obj)
  if obj.nil?
    false
  elsif !obj.instance_of?(NegationMatcher)
    false
  elsif self.equal?(obj)
    true
  else
    false
  end
end

#match?(key, attributes) ⇒ 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



22
23
24
# File 'lib/engine/matchers/negation_matcher.rb', line 22

def match?(key, attributes)
  !@matcher.match?(key, attributes)
end

#to_sObject

function to print string value for this matcher



48
49
50
# File 'lib/engine/matchers/negation_matcher.rb', line 48

def to_s
  'not ' + @matcher.to_s
end