Module: DecisionAgent::Dsl::Helpers::OperatorEvaluationHelpers
- Defined in:
- lib/decision_agent/dsl/helpers/operator_evaluation_helpers.rb
Overview
Operator evaluation helpers for ConditionEvaluator
Class Method Summary collapse
-
.evaluate_operator(op, actual_value, expected_value, context_hash, regex_cache:, regex_cache_mutex:, param_cache:, param_cache_mutex:, geospatial_cache:, geospatial_cache_mutex:) ⇒ Object
Evaluates operator using mixins (in order of most common to least common) Returns the result from the first mixin that handles the operator, or false if unknown.
- .try_advanced_operators(op, actual_value, expected_value, param_cache:, param_cache_mutex:) ⇒ Object
- .try_basic_operators(op, actual_value, expected_value, regex_cache:, regex_cache_mutex:, param_cache:, param_cache_mutex:) ⇒ Object
- .try_collection_and_aggregation_operators(op, actual_value, expected_value, param_cache:, param_cache_mutex:) ⇒ Object
- .try_datetime_operators(op, actual_value, expected_value, context_hash, param_cache:, param_cache_mutex:) ⇒ Object
- .try_math_and_statistical_operators(op, actual_value, expected_value, param_cache:, param_cache_mutex:) ⇒ Object
- .try_special_operators(op, actual_value, expected_value, _context_hash, geospatial_cache:, geospatial_cache_mutex:) ⇒ Object
Class Method Details
.evaluate_operator(op, actual_value, expected_value, context_hash, regex_cache:, regex_cache_mutex:, param_cache:, param_cache_mutex:, geospatial_cache:, geospatial_cache_mutex:) ⇒ Object
Evaluates operator using mixins (in order of most common to least common) Returns the result from the first mixin that handles the operator, or false if unknown
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/decision_agent/dsl/helpers/operator_evaluation_helpers.rb', line 10 def self.evaluate_operator(op, actual_value, expected_value, context_hash, regex_cache:, regex_cache_mutex:, param_cache:, param_cache_mutex:, geospatial_cache:, geospatial_cache_mutex:) # Try basic operators first (most common) result = try_basic_operators( op, actual_value, expected_value, regex_cache: regex_cache, regex_cache_mutex: regex_cache_mutex, param_cache: param_cache, param_cache_mutex: param_cache_mutex ) return result unless result.nil? # Try mathematical and statistical operators result = try_math_and_statistical_operators( op, actual_value, expected_value, param_cache: param_cache, param_cache_mutex: param_cache_mutex ) return result unless result.nil? # Try date/time operators result = try_datetime_operators( op, actual_value, expected_value, context_hash, param_cache: param_cache, param_cache_mutex: param_cache_mutex ) return result unless result.nil? # Try advanced operators (rate, moving window, financial) result = try_advanced_operators( op, actual_value, expected_value, param_cache: param_cache, param_cache_mutex: param_cache_mutex ) return result unless result.nil? # Try collection and aggregation operators result = try_collection_and_aggregation_operators( op, actual_value, expected_value, param_cache: param_cache, param_cache_mutex: param_cache_mutex ) return result unless result.nil? # Try special operators (geospatial, data enrichment) result = try_special_operators( op, actual_value, expected_value, context_hash, geospatial_cache: geospatial_cache, geospatial_cache_mutex: geospatial_cache_mutex ) return result unless result.nil? # Unknown operator - returns false (fail-safe) # Note: Validation should catch this earlier false end |
.try_advanced_operators(op, actual_value, expected_value, param_cache:, param_cache_mutex:) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/decision_agent/dsl/helpers/operator_evaluation_helpers.rb', line 121 def self.try_advanced_operators(op, actual_value, expected_value, param_cache:, param_cache_mutex:) result = Operators::RateOperators.handle(op, actual_value, expected_value) return result unless result.nil? result = Operators::MovingWindowOperators.handle( op, actual_value, expected_value, param_cache: param_cache, param_cache_mutex: param_cache_mutex ) return result unless result.nil? Operators::FinancialOperators.handle( op, actual_value, expected_value, param_cache: param_cache, param_cache_mutex: param_cache_mutex ) end |
.try_basic_operators(op, actual_value, expected_value, regex_cache:, regex_cache_mutex:, param_cache:, param_cache_mutex:) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/decision_agent/dsl/helpers/operator_evaluation_helpers.rb', line 67 def self.try_basic_operators(op, actual_value, expected_value, regex_cache:, regex_cache_mutex:, param_cache:, param_cache_mutex:) result = Operators::BasicComparisonOperators.handle(op, actual_value, expected_value) return result unless result.nil? result = Operators::StringOperators.handle( op, actual_value, expected_value, regex_cache: regex_cache, regex_cache_mutex: regex_cache_mutex ) return result unless result.nil? Operators::NumericOperators.handle( op, actual_value, expected_value, param_cache: param_cache, param_cache_mutex: param_cache_mutex ) end |
.try_collection_and_aggregation_operators(op, actual_value, expected_value, param_cache:, param_cache_mutex:) ⇒ Object
139 140 141 142 143 144 145 146 147 148 |
# File 'lib/decision_agent/dsl/helpers/operator_evaluation_helpers.rb', line 139 def self.try_collection_and_aggregation_operators(op, actual_value, expected_value, param_cache:, param_cache_mutex:) result = Operators::StringAggregations.handle( op, actual_value, expected_value, param_cache: param_cache, param_cache_mutex: param_cache_mutex ) return result unless result.nil? Operators::CollectionOperators.handle(op, actual_value, expected_value) end |
.try_datetime_operators(op, actual_value, expected_value, context_hash, param_cache:, param_cache_mutex:) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/decision_agent/dsl/helpers/operator_evaluation_helpers.rb', line 100 def self.try_datetime_operators(op, actual_value, expected_value, context_hash, param_cache:, param_cache_mutex:) result = Operators::DateTimeOperators.handle(op, actual_value, expected_value) return result unless result.nil? result = Operators::DurationOperators.handle( op, actual_value, expected_value, context_hash, param_cache: param_cache, param_cache_mutex: param_cache_mutex ) return result unless result.nil? result = Operators::DateArithmeticOperators.handle( op, actual_value, expected_value, context_hash, param_cache: param_cache, param_cache_mutex: param_cache_mutex ) return result unless result.nil? Operators::TimeComponentOperators.handle(op, actual_value, expected_value) end |
.try_math_and_statistical_operators(op, actual_value, expected_value, param_cache:, param_cache_mutex:) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/decision_agent/dsl/helpers/operator_evaluation_helpers.rb', line 85 def self.try_math_and_statistical_operators(op, actual_value, expected_value, param_cache:, param_cache_mutex:) result = Operators::MathematicalOperators.handle( op, actual_value, expected_value, param_cache: param_cache, param_cache_mutex: param_cache_mutex ) return result unless result.nil? Operators::StatisticalAggregations.handle( op, actual_value, expected_value, param_cache: param_cache, param_cache_mutex: param_cache_mutex ) end |
.try_special_operators(op, actual_value, expected_value, _context_hash, geospatial_cache:, geospatial_cache_mutex:) ⇒ Object
150 151 152 153 154 155 156 |
# File 'lib/decision_agent/dsl/helpers/operator_evaluation_helpers.rb', line 150 def self.try_special_operators(op, actual_value, expected_value, _context_hash, geospatial_cache:, geospatial_cache_mutex:) Operators::GeospatialOperators.handle( op, actual_value, expected_value, geospatial_cache: geospatial_cache, geospatial_cache_mutex: geospatial_cache_mutex ) end |