Sha256: a1cf718ad0dae206f4513083ff3dbf9d37073be1737c1ac7b96060adec5ec11c

Contents?: true

Size: 456 Bytes

Versions: 2

Compression:

Stored size: 456 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?(_key, 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.include? substr }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
splitclient-rb-4.1.0.pre.rc2 lib/engine/matchers/contains_matcher.rb
splitclient-rb-4.1.0.pre.rc1 lib/engine/matchers/contains_matcher.rb