Class: Hackle::ExperimentEvaluatorMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/hackle/internal/evaluation/match/condition/experiment/experiment_evaluator_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(evaluator:) ⇒ ExperimentEvaluatorMatcher

Returns a new instance of ExperimentEvaluatorMatcher.

Parameters:



9
10
11
12
# File 'lib/hackle/internal/evaluation/match/condition/experiment/experiment_evaluator_matcher.rb', line 9

def initialize(evaluator:)
  # @type [Evaluator]
  @evaluator = evaluator
end

Instance Method Details

#matches(request, context, condition) ⇒ boolean

Parameters:

Returns:

  • (boolean)

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/hackle/internal/evaluation/match/condition/experiment/experiment_evaluator_matcher.rb', line 18

def matches(request, context, condition)
  key = Integer(condition.key.name, exception: false)
  raise ArgumentError, "invalid key [#{condition.key.type}, #{condition.key.name}]" if key.nil?

  experiment = experiment_or_nil(request, key)
  return false if experiment.nil?

  evaluation = get_evaluation_or_nil(context, experiment)
  evaluation = evaluate(request, context, experiment) if evaluation.nil?

  evaluation_matches(evaluation, condition)
end