Sha256: 16cb5a2bb30d7906d4efa45241cddd5d2264b164d83c35d31fb35b122c11a8e0

Contents?: true

Size: 498 Bytes

Versions: 3

Compression:

Stored size: 498 Bytes

Contents

module SplitIoClient
  class ContainsMatcher
    def self.matcher_type
      'CONTAINS_WITH'.freeze
    end

    def initialize(attribute, substr_list)
      @attribute = attribute
      @substr_list = substr_list
    end

    def match?(_matching_key, _bucketing_key, _evaluator, data)
      value = data.fetch(@attribute) { |attr| data[attr.to_s] || data[attr.to_sym] }

      return false if @substr_list.empty?

      @substr_list.any? { |substr| value.to_s.include? substr }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
splitclient-rb-4.2.2 lib/splitclient-rb/engine/matchers/contains_matcher.rb
splitclient-rb-4.2.1 lib/splitclient-rb/engine/matchers/contains_matcher.rb
splitclient-rb-4.2.0 lib/splitclient-rb/engine/matchers/contains_matcher.rb