class SplitIoClient::CombiningMatcher
class to implement the combining matcher
def eval_and(args)
-
(boolean)- match value for combiner delegates
Parameters:
-
attributes(hash) -- attributes to pass to the treatment class -
evaluator(Evaluator) -- used in dependency_matcher -
bucketing_key(string) -- bucketing key to be matched -
matching_key(string) -- key value to be matched
def eval_and(args) # Convert all keys to symbols args[:attributes] = args[:attributes].each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v } if args && args[:attributes] @matchers.all? do |matcher| if match_with_key?(matcher) matcher.match?(value: args[:matching_key]) else matcher.match?(args) end end end
def initialize(logger, combiner = '', matchers = [])
def initialize(logger, combiner = '', matchers = []) super(logger) @combiner = combiner @matchers = matchers end
def match?(args)
-
(boolean)-
Parameters:
-
attributes(hash) -- -
evaluator(instance of Evaluator class) -- -
bucketing_key(string) -- bucketing key to be matched -
matching_key(string) -- key value to be matched
def match?(args) if @matchers.empty? @logger.log_if_debug('[CombiningMatcher] Matchers Empty') return false end case @combiner when Combiners::AND matches = eval_and(args) @logger.log_if_debug("[CombiningMatcher] Combiner AND result -> #{matches}") return matches else @logger.log_if_debug("[CombiningMatcher] Invalid Combiner Type - Combiner -> #{@combiner}") @logger.error('Invalid combiner type') end false end
def match_with_key?(matcher)
def match_with_key?(matcher) matcher.respond_to?(:attribute) && matcher.attribute.nil? && matcher.string_type? end
def to_s
-
(string)- string value of this matcher
def to_s @matcher_list.map(&:to_s).join("#{@combiner} ") end