-
Notifications
You must be signed in to change notification settings - Fork 34
Description
I've noticed that the operations in this port work entirely different then they do in the original JS port.
Specifically here:
json-logic-ruby/lib/json_logic/operation.rb
Line 117 in 97b4b5d
return LAMBDAS[operator.to_s].call(interpolated, data) if is_standard?(operator) |
JSONLogic is defined to accept the elements in an array as the argument to an operation.
However, your operations accept an array and the original data object.
With all the testing I've done so far, it seems like everything officially supported in the JS port works the same in this Ruby port.
Ex)
rule = {+: [1, 2]}
data = {}
JSONLogic.apply(rule, data) # 3
The result of this will be 3
in both ports ✅
However, if you were to define something like this in ruby:
rule = {+: [{var: 'data'}]}
data = {data: [1,2]}
JSONLogic.apply(rule, data) # 3
and in JS
rule = {"+": [{"var": "data"}]}
data = {"data": [1,2]}
jsonLogic.apply(rule, data) # 1
You end up with 3
in Ruby and 1
in JS. ❌
Ultimately this leads to inconsistencies when trying to develop cross-platform.