Sha256: a86d7a5bf4cd56c265907f1ebd294fcd34a6ec42c139961d8bcfa7cb0cb19aac

Contents?: true

Size: 823 Bytes

Versions: 300

Compression:

Stored size: 823 Bytes

Contents

# frozen_string_literal: true

module SplitIoClient
  class EqualToBooleanMatcher
    MATCHER_TYPE = 'EQUAL_TO_BOOLEAN'

    attr_reader :attribute

    def initialize(attribute, boolean, logger)
      @attribute = attribute
      @boolean = boolean
      @logger = logger
    end

    def match?(args)
      value = get_value(args)
      value = false if value.to_s.casecmp('false').zero?
      value = true if value.to_s.casecmp('true').zero?

      matches = value == @boolean
      @logger.log_if_debug("[EqualToBooleanMatcher] #{value} equals to #{@boolean} -> #{matches}")
      matches
    end

    def string_type?
      false
    end

    private

    def get_value(args)
      args[:attributes].fetch(@attribute) do |a|
        args[:attributes][a.to_s] || args[:attributes][a.to_sym]
      end
    end
  end
end

Version data entries

300 entries across 300 versions & 1 rubygems

Version Path
splitclient-rb-7.0.1.pre.rc7-java lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.1.pre.rc7 lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.1.pre.rc6-java lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.1.pre.rc6 lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.1.pre.rc5-java lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.1.pre.rc5 lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.1.pre.rc4-java lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.1.pre.rc4 lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.1.pre.rc3-java lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.1.pre.rc3 lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.1.pre.rc1-java lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.1.pre.rc1 lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.0-java lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.0 lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.0.pre.rc3-java lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.0.pre.rc3 lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.0.pre.rc2-java lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.0.pre.rc2 lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.0.pre.rc1-java lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb
splitclient-rb-7.0.0.pre.rc1 lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb