Skip to content
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

Stripe gem not compatible with awesome print due to metaprogramming method usage #524

Closed
fatuhoku opened this issue Apr 4, 2017 · 5 comments

Comments

@fatuhoku
Copy link

fatuhoku commented Apr 4, 2017

For more info please see the issue here: awesome-print/awesome_print#306 (comment)

For your benefit I re-paste the trace that shows reproduces the error:

> p Stripe::Transfer.retrieve("some_valid_transfer_id") # this works...
#<Stripe::Transfer:0x3fc9e98156e4 id=some_valid_transfer_id> JSON: {
  "id": "some_valid_transfer_id",
  "object": "transfer",
  ... # blah blah blah blah
}
(pry) output error: #<ArgumentError: wrong number of arguments (1 for 0)>

> ap Stripe::Transfer.retrieve("some_valid_transfer_id") # this doesn't work at all
ArgumentError: wrong number of arguments (1 for 0)
from ~/.rvm/gems/ruby-2.2.4/gems/stripe-2.1.0/lib/stripe/stripe_object.rb:241:in `block (3 levels) in add_accessors'

Stripe gem version: 2.1.0
Ruby version: 2.2.4

@brandur-stripe
Copy link
Contributor

Sorry about the trouble and thanks for the report. This is certainly a problem. I'm not quite sure yet what the best way to fix this one is yet. Let me get back to you on it.

@jakeonrails
Copy link

Just a suggestion, @brandur-stripe: For this specific case when a user is normally calling method to get a Ruby Method object as a result, they are required to pass a parameter. So you could override the attr_accessor for a method attribute to check the arity of the *args passed in, and if there are any arguments, call super, but if none are passed, then return the attribute named method. It's a brutal hack, but it could solve this particular issue without any product or Ruby API changes.

@brandur-stripe
Copy link
Contributor

@jakeonrails Great point! Thank you for the suggestion; I'll certainly bring it up as a possibility.

I suspect that we're going to need a more general approach to this at some point because we're seeing it in a few other places. For example, we smashed Python's items keyword on Subscription over in stripe/stripe-python#297.

@brandur-stripe
Copy link
Contributor

I'm adding some linters to make sure that we don't introduce anymore of these, and I think we'll probably end up putting in an API version to change the existing instances to something a little better (that's still a little in the air though).

@brandur-stripe
Copy link
Contributor

Fixed released as part of 3.5.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants