Method: Optimizely::ConditionTreeEvaluator.or_evaluator
- Defined in:
- lib/optimizely/condition_tree_evaluator.rb
.or_evaluator(conditions, leaf_evaluator) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/optimizely/condition_tree_evaluator.rb', line 99 def or_evaluator(conditions, leaf_evaluator) # Evaluates an array of conditions as if the evaluator had been applied # to each entry and the results OR-ed together. # # conditions - Array of conditions ex: [operand_1, operand_2] # # leaf_evaluator - Function which will be called to evaluate leaf condition values. # # Returns boolean if the user attributes match/don't match the given conditions, # nil if the user attributes and conditions can't be evaluated. found_nil = false conditions.each do |condition| result = evaluate(condition, leaf_evaluator) return result if result == true found_nil = true if result.nil? end found_nil ? nil : false end |