Sha256: 2ef40fd419cf78cbadd8752eee08f36b2de2ffb5f0c974e47297630997da88b0

Contents?: true

Size: 576 Bytes

Versions: 2

Compression:

Stored size: 576 Bytes

Contents

module SplitIoClient
  class AttributeMatcher
    def initialize(attribute, matcher)
      @attribute = attribute
      @matcher = matcher
    end

    def match?(matching_key, bucketing_key = nil, evaluator = nil, attributes = {})
      if @attribute != nil
        return false unless attributes

        value = attributes.fetch(@attribute) { |name| attributes[name.to_s] || attributes[name.to_sym] }

        @matcher.match?(value, bucketing_key, nil, nil)
      else
        @matcher.match?(matching_key, bucketing_key, evaluator, attributes)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
splitclient-rb-4.3.0.canary.2 lib/splitclient-rb/engine/matchers/attribute_matcher.rb
splitclient-rb-4.3.0.canary.1 lib/splitclient-rb/engine/matchers/attribute_matcher.rb