Sha256: d9539dc28f53ac71a0043addb96fbe2439c49ba14f026a104ff4c35e52921bb1

Contents?: true

Size: 722 Bytes

Versions: 28

Compression:

Stored size: 722 Bytes

Contents

# frozen_string_literal: true

module SplitIoClient
  class MatchesStringMatcher
    MATCHER_TYPE = 'MATCHES_STRING'

    attr_reader :attribute

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

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

      matches = !(value =~ @regexp_string).nil?
      SplitLogger.log_if_debug("[MatchesStringMatcher] #{value} matches #{@regexp_string} -> #{matches}")
      matches
    end

    def string_type?
      true
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
splitclient-rb-6.4.1-java lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.4.1 lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.4.1.pre.rc3-java lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.4.1.pre.rc3 lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.4.1.pre.rc2-java lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.4.1.pre.rc2 lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.4.1.pre.rc1-java lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.4.1.pre.rc1 lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.4.0-java lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.4.0 lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.4.0.pre.rc1-java lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.4.0.pre.rc1 lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.3.0-java lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.3.0 lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.3.0.pre.rc1-java lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.3.0.pre.rc1 lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.2.0-java lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.2.0 lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.2.0.pre.rc2-java lib/splitclient-rb/engine/matchers/matches_string_matcher.rb
splitclient-rb-6.2.0.pre.rc2 lib/splitclient-rb/engine/matchers/matches_string_matcher.rb