Skip to content

Functional differences between this and original JS port #18

Description

@PeterLanglois

I've noticed that the operations in this port work entirely different then they do in the original JS port.
Specifically here:

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions