You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 30, 2019. It is now read-only.
I have a situation where, based upon certain parameters, I would include certain parts of the object in the response, but it seems this cannot be done with json_builder.
ex:
foos@foosdo |foo|
...
# can't do thisif@opts[include_bars]thingsfoo.barsdo |bar|
...
endendend
The text was updated successfully, but these errors were encountered:
It seems that the last expression in the block (the return value) is used to decide what value 'foos' will be.
If the return statement is the result of one of json_builder's attributes, it knows how to handle that.
If it is any other value, it ignores any uses of json_builder's attributes inside the block and use the return value as the value which called the block.
In case of an if statement. When it's true, the if statement's return value is the last expression of the if block, most likely a json_builder attribute.
When it's false, the return value is nil and that return value is used for the outer block.
This is a tough problem to fix. In the mean time I use a mock value after the if statement, something like foo 'bar' to make sure to prevent the above problem from occurring.
I have a situation where, based upon certain parameters, I would include certain parts of the object in the response, but it seems this cannot be done with json_builder.
ex:
The text was updated successfully, but these errors were encountered: