Sha256: 5e12d0cc43306100a423544fc617710bf28ac80061d339d6ad0e94c878677437

Contents?: true

Size: 501 Bytes

Versions: 2

Compression:

Stored size: 501 Bytes

Contents

module SplitIoClient
  class MatchesStringMatcher
    def self.matcher_type
      'MATCHES_STRING'.freeze
    end

    def initialize(attribute, regexp_string)
      @attribute = attribute
      @regexp_string = @regexp_string.is_a?(Regexp) ? regexp_string : Regexp.new(regexp_string)
    end

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

      (value =~ @regexp_string) != nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
splitclient-rb-4.2.2 lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-4.2.1 lib/splitclient-rb/engine/matchers/matches_string_matcher.rb