Class: SplitIoClient::PrerequisitesMatcher

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

Instance Method Summary collapse

Constructor Details

#initialize(prerequisites, logger) ⇒ PrerequisitesMatcher

Returns a new instance of PrerequisitesMatcher.



5
6
7
8
# File 'lib/splitclient-rb/engine/matchers/prerequisites_matcher.rb', line 5

def initialize(prerequisites, logger)
  @prerequisites = prerequisites
  @logger = logger
end

Instance Method Details

#match?(args) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/splitclient-rb/engine/matchers/prerequisites_matcher.rb', line 10

def match?(args)
  keys = { matching_key: args[:matching_key], bucketing_key: args[:bucketing_key] }

  match = true
  @prerequisites.each do |prerequisite|
    evaluate = args[:evaluator].evaluate_feature_flag(keys, prerequisite[:n], args[:attributes])
    next if prerequisite[:ts].include?(evaluate[:treatment])

    @logger.log_if_debug("[PrerequisitesMatcher] feature flag #{prerequisite[:n]} evaluated to #{evaluate[:treatment]} \
      that does not exist in prerequisited treatments.")
    match = false
    break
  end

  match
end

#string_type?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/splitclient-rb/engine/matchers/prerequisites_matcher.rb', line 27

def string_type?
  false
end