Class: SplitIoClient::DependencyMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/splitclient-rb/engine/matchers/dependency_matcher.rb

Constant Summary collapse

MATCHER_TYPE =
'IN_SPLIT_TREATMENT'

Instance Method Summary collapse

Constructor Details

#initialize(split, treatments, logger) ⇒ DependencyMatcher

Returns a new instance of DependencyMatcher.



7
8
9
10
11
# File 'lib/splitclient-rb/engine/matchers/dependency_matcher.rb', line 7

def initialize(split, treatments, logger)
  @split = split
  @treatments = treatments
  @logger = logger
end

Instance Method Details

#match?(args) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
# File 'lib/splitclient-rb/engine/matchers/dependency_matcher.rb', line 13

def match?(args)
  keys = { matching_key: args[:matching_key], bucketing_key: args[:bucketing_key] }
  evaluate = args[:evaluator].call(keys, @split, args[:attributes])
  matches = @treatments.include?(evaluate[:treatment])
  @logger.log_if_debug("[dependencyMatcher] Parent split #{@split} evaluated to #{evaluate[:treatment]} \
    with label #{evaluate[:label]}. #{@split} evaluated treatment is part of [#{@treatments}] ? #{matches}.")
  matches
end

#string_type?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/splitclient-rb/engine/matchers/dependency_matcher.rb', line 22

def string_type?
  false
end