Module: JsonLogic::Trackable
- Included in:
- Evaluator
- Defined in:
- lib/json_logic/concerns/trackable.rb
Constant Summary collapse
- COMPLEX_OPERATORS =
%w[and or if ! !! ?:].freeze
Instance Attribute Summary collapse
-
#tracker ⇒ Object
readonly
Returns the value of attribute tracker.
Instance Method Summary collapse
Instance Attribute Details
#tracker ⇒ Object (readonly)
Returns the value of attribute tracker.
7 8 9 |
# File 'lib/json_logic/concerns/trackable.rb', line 7 def tracker @tracker end |
Instance Method Details
#commit_rule_result!(operator, data, rules, result) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/json_logic/concerns/trackable.rb', line 17 def commit_rule_result!(operator, data, rules, result) if COMPLEX_OPERATORS.include?(operator) # change operand to parent & save result @tracker.result = result @tracker = @tracker.parent unless @tracker.parent.nil? return result end var_name = get_var_name(operator, rules) @tracker.add_data_point(var_name, operator, rules, data, result) result end |
#init_tracker(operator) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/json_logic/concerns/trackable.rb', line 9 def init_tracker(operator) if @tracker.nil? @tracker = Rule.new(operator) elsif COMPLEX_OPERATORS.include?(operator) @tracker = Rule.new(operator, @tracker) end end |