-
Notifications
You must be signed in to change notification settings - Fork 546
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
StripeObject#method_missing doesn't agree with StripeObject#respond_to_missing? #324
Comments
Thanks for writing in @bloopletech! So although a discrepancy around The most obvious thing to do here is to loosen its constraints so that they fall in-line with direct assignment. In a way I hate to do this though, because we'd be giving up one of the very, very few places in this gem where we've managed to put any kind of safety in. Another possibility is that we could add I'm probably going to lean toward the latter solution unless some other ideas are presented here. /cc @kyleconroy |
Hmm, I think |
This dials down the safety of `StripeObject`'s `#update_attributes` method so that it allows properties to be assigned that it doesn't yet know about. We're doing this for a few reasons: 1. To reflect the current behavior of accessors (i.e. `obj.name = ...`) through `method_missing`. 2. To allow `#update_attributes` to assign properties on new projects that don't yet know their schema from an API call. Fixes #324.
Yeah, good call. Dialed down safety to fix this issue in #329. |
Awesome! Thanks for looking at this issue. |
Example:
The #method_missing implementation on StripeObject allows the user to assign arbitrary key/values into the @values hash. However, #respond_to_missing? only returns true if the method name passed in matches a key that is already in the @values hash.
This has follow on effects which I'm going to write up into a separate issue, but an example of the other issues this introduces is:
Because #update_attributes_with_options calls #respond_to? to check whether to allow the assignment, it will fail until something either adds the key to @values, or adds the accessor method to the object.
The text was updated successfully, but these errors were encountered: