Sha256: b631c8d63bf6dde9e1f5fb21289be350da67e564bf903b485066d8a1788f0414

Contents?: true

Size: 495 Bytes

Versions: 3

Compression:

Stored size: 495 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?(_matching_key, _bucketing_key, _evaluator, 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.to_s.end_with? suffix }
    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/ends_with_matcher.rb
splitclient-rb-4.2.1 lib/splitclient-rb/engine/matchers/ends_with_matcher.rb
splitclient-rb-4.2.0 lib/splitclient-rb/engine/matchers/ends_with_matcher.rb