Sha256: 0e4798bd96e6dcea49b208aae7a624677e4cbe2c6509bb59f0cacabcac8c2c96

Contents?: true

Size: 453 Bytes

Versions: 2

Compression:

Stored size: 453 Bytes

Contents

module SplitIoClient
  class EndsWithMatcher
    def self.matcher_type
      'ENDS_WITH'.freeze
    end

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

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

      return false if @suffix_list.empty?

      @suffix_list.any? { |suffix| value.end_with? suffix }
    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/ends_with_matcher.rb
splitclient-rb-4.1.0.pre.rc1 lib/engine/matchers/ends_with_matcher.rb