Class: Hackle::ExperimentEvaluatorMatcher
- Inherits:
-
Object
- Object
- Hackle::ExperimentEvaluatorMatcher
- Defined in:
- lib/hackle/internal/evaluation/match/condition/experiment/experiment_evaluator_matcher.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(evaluator:) ⇒ ExperimentEvaluatorMatcher
constructor
A new instance of ExperimentEvaluatorMatcher.
- #matches(request, context, condition) ⇒ boolean
Constructor Details
#initialize(evaluator:) ⇒ ExperimentEvaluatorMatcher
Returns a new instance of ExperimentEvaluatorMatcher.
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
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 |