Sha256: 271bf3a33f35332121442132c6c72d62d06d220cd832eb6a1cfe1b55b905c632

Contents?: true

Size: 459 Bytes

Versions: 2

Compression:

Stored size: 459 Bytes

Contents

module SplitIoClient
  class StartsWithMatcher
    def self.matcher_type
      'STARTS_WITH'.freeze
    end

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

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

      return false if @prefix_list.empty?

      @prefix_list.any? { |prefix| value.start_with? prefix }
    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/starts_with_matcher.rb
splitclient-rb-4.1.0.pre.rc1 lib/engine/matchers/starts_with_matcher.rb