Sha256: 3310f77ddebc0f3cf0f4174ca2418eda27e17eef50f8ec04812eb7435d6a32e8

Contents?: true

Size: 767 Bytes

Versions: 62

Compression:

Stored size: 767 Bytes

Contents

module SplitIoClient
  class ContainsMatcher
    MATCHER_TYPE = 'CONTAINS_WITH'.freeze

    attr_reader :attribute

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

    def match?(args)
      return false if !args.key?(:attributes) && !args.key?(:value)
      return false if args.key?(:value) && args[:value].nil?
      return false if args.key?(:attributes) && args[:attributes].nil?

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

      return false if @substr_list.empty?

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

    def string_type?
      true
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
splitclient-rb-4.3.1 lib/splitclient-rb/engine/matchers/contains_matcher.rb
splitclient-rb-4.3.0 lib/splitclient-rb/engine/matchers/contains_matcher.rb