-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Link method_missing delegation wrongly returns nil when field value is false #126
Labels
Comments
Your fix looks right, make a PR! |
ivoanjo
added a commit
that referenced
this issue
Aug 26, 2017
Whenever a resource includes a field that is `false`, trying to access it through a `Link` returned `nil`, rather than `false`. This is because `Link` confused the `false` response with the resource not actually handling the value, and then tried to use the delegation as if a collection method was being called on the resource. Fixes #126
ivoanjo
added a commit
that referenced
this issue
Aug 26, 2017
Whenever a resource includes a field that is `false`, trying to access it through a `Link` returned `nil`, rather than `false`. This is because `Link` confused the `false` response with the resource not actually handling the value, and then tried to use the delegation as if a collection method was being called on the resource. Fixes #126
dblock
pushed a commit
that referenced
this issue
Aug 26, 2017
* Fix link delegation returning nil for field with value false Whenever a resource includes a field that is `false`, trying to access it through a `Link` returned `nil`, rather than `false`. This is because `Link` confused the `false` response with the resource not actually handling the value, and then tried to use the delegation as if a collection method was being called on the resource. Fixes #126 * Update CHANGELOG
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When a resource includes some field that is
false
, trying to read it through theLink
class will result in the value being returned asnil
instead offalse
.Test case:
Current result:
This seems to me to be due to a bad interaction in
Link#method_missing
(https://github.com/codegram/hyperclient/blob/master/lib/hyperclient/link.rb#L129):In this case,
_resource.send(method, *args, &block)
is returningfalse
, which we are mistaking for the case where we're trying to call an array method on the resource, and thus instead of returningfalse
we are callingdelegate_method
(which will then return thenil
).I was thinking about it and it seems to me that changing it to treat
false
differently would fix the issue:But I was not entirely sure, hence I decided to open an issue first, instead of jumping straight to a PR. Any thoughts on this approach?
The text was updated successfully, but these errors were encountered: