Sha256: 6bf26e2295ec8056c143d8898da5a4eaf11962fa0365ea59486a61302832c51a

Contents?: true

Size: 1.07 KB

Versions: 12

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module SplitIoClient
  class InListSemverMatcher < Matcher
    MATCHER_TYPE = 'IN_LIST_SEMVER'

    attr_reader :attribute

    def initialize(attribute, list_value, logger, validator)
      super(logger)
      @validator = validator
      @attribute = attribute
      @semver_list = []

      list_value.map do |item|
        version = SplitIoClient::Semver.build(item, logger)
        @semver_list << version unless version.nil?
      end
      @logger = logger
    end

    def match?(args)
      return false if @semver_list.empty? || !verify_semver_arg?(args, 'InListSemverMatcher')

      value_to_match = SplitIoClient::Semver.build(args[:attributes][@attribute.to_sym], @logger)
      if value_to_match.nil?
        @logger.error('whitelistMatcherData is required for IN_LIST_SEMVER matcher type')
        return false

      end
      matches = (@semver_list.map { |item| item.version == value_to_match.version }).any? { |item| item == true }
      @logger.debug("[InListSemverMatcher] #{value_to_match} matches -> #{matches}")
      matches
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
splitclient-rb-8.5.0-java lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb
splitclient-rb-8.5.0 lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb
splitclient-rb-8.5.0.pre.rc1-java lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb
splitclient-rb-8.5.0.pre.rc1 lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb
splitclient-rb-8.4.1.pre.rc1-java lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb
splitclient-rb-8.4.1.pre.rc1 lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb
splitclient-rb-8.4.0-java lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb
splitclient-rb-8.4.0 lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb
splitclient-rb-8.4.0.pre.rc1-java lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb
splitclient-rb-8.4.0.pre.rc1 lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb
splitclient-rb-8.4.0.rc.1-java lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb
splitclient-rb-8.4.0.rc.1 lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb