Sha256: 18398b35bf766be9e6ba510909af3434976aac23866be6fef960378d091c6eee

Contents?: true

Size: 563 Bytes

Versions: 62

Compression:

Stored size: 563 Bytes

Contents

module SplitIoClient
  class EndsWithMatcher
    MATCHER_TYPE = 'ENDS_WITH'.freeze

    attr_reader :attribute

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

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

      return false if @suffix_list.empty?

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