fast_jsonapi
fast_jsonapi copied to clipboard
Flipped ArgumentError with conditional attributes
Conditional attributes are throwing me an ArgumentError if I don't give two arguments to the Proc passed to the if: keyword:
attribute :my_attribute, if: ->(obj) { obj.my_condition }
returns ArgumentError: wrong number of arguments (given 2, expected 1) (shouldn't it be the other way around, if anything?)
Passing a second argument, on the other hand, makes things work just fine:
attribute :my_attribute, if: ->(obj, _) { obj.my_condition }
@coconup if params are not passed in we should probably set it to a default empty hash. Is this something you can make a pull request for ?
@shishirmk here you go: https://github.com/Netflix/fast_jsonapi/pull/305