Sha256: 6fd4717b0adcfbb56c5d29cc3fdd139fa0badbdcb90f919b70b29956bafe97aa

Contents?: true

Size: 988 Bytes

Versions: 28

Compression:

Stored size: 988 Bytes

Contents

# frozen_string_literal: true

module SplitIoClient
  #
  # class to implement the negation of a matcher
  #
  class NegationMatcher < Matcher
    MATCHER_TYPE = 'NEGATION_MATCHER'

    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?(args)
      matches = !@matcher.match?(args)
      SplitLogger.log_if_debug("[NegationMatcherMatcher] Matcher #{@matcher} Arguments #{args} -> #{matches}")
      matches
    end

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

    def attribute
      @matcher.attribute
    end

    def string_type?
      @matcher.string_type?
    end

    #
    # function to print string value for this matcher
    #
    # @return [string] string value of this matcher
    def to_s
      "not #{@matcher}"
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
splitclient-rb-6.4.1-java lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.4.1 lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.4.1.pre.rc3-java lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.4.1.pre.rc3 lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.4.1.pre.rc2-java lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.4.1.pre.rc2 lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.4.1.pre.rc1-java lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.4.1.pre.rc1 lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.4.0-java lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.4.0 lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.4.0.pre.rc1-java lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.4.0.pre.rc1 lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.3.0-java lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.3.0 lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.3.0.pre.rc1-java lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.3.0.pre.rc1 lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.2.0-java lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.2.0 lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.2.0.pre.rc2-java lib/splitclient-rb/engine/matchers/negation_matcher.rb
splitclient-rb-6.2.0.pre.rc2 lib/splitclient-rb/engine/matchers/negation_matcher.rb