Closed fatuhoku closed 7 years ago
Do you have more backtrace? Esp. any lines that are actually from awesome_print?
Nope. You can see from the lines I've posted that the problem doesn't exist with p
and does for ap
. As a user of awesome-print and Stripe I have no idea how the guts of either have caused this bizarre error. I mean, how could I?
ArgumentError: wrong number of arguments (given 1, expected 0)
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/stripe-1.55.0/lib/stripe/stripe_object.rb:231:in `block (3 levels) in add_accessors'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/awesome_print-1.7.0/lib/awesome_print/formatter.rb:122:in `convert_to_hash'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/awesome_print-1.7.0/lib/awesome_print/formatter.rb:55:in `awesome_self'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/awesome_print-1.7.0/lib/awesome_print/formatter.rb:36:in `format'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/awesome_print-1.7.0/lib/awesome_print/inspector.rb:148:in `unnested'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/awesome_print-1.7.0/lib/awesome_print/inspector.rb:115:in `awesome'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/awesome_print-1.7.0/lib/awesome_print/core_ext/kernel.rb:10:in `ai'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/awesome_print-1.7.0/lib/awesome_print/core_ext/kernel.rb:20:in `ap'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/awesome_print-1.7.0/lib/awesome_print/inspector.rb:33:in `output_value'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/railties-4.2.8/lib/rails/commands/console.rb:110:in `start'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/railties-4.2.8/lib/rails/commands/console.rb:9:in `start'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/railties-4.2.8/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `require'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:274:in `block in require'
... 3 levels...
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `load'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `block in load'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:268:in `load'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/spring-1.7.2/lib/spring/commands/rails.rb:6:in `call'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/spring-1.7.2/lib/spring/command_wrapper.rb:38:in `call'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/spring-1.7.2/lib/spring/application.rb:191:in `block in serve'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/spring-1.7.2/lib/spring/application.rb:161:in `fork'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/spring-1.7.2/lib/spring/application.rb:161:in `serve'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/spring-1.7.2/lib/spring/application.rb:131:in `block in run'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/spring-1.7.2/lib/spring/application.rb:125:in `loop'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/spring-1.7.2/lib/spring/application.rb:125:in `run'
from /Users/jakemoffatt/.rvm/gems/ruby-2.3.3@mobile-notary/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /Users/jakemoffatt/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/jakemoffatt/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
https://github.com/awesome-print/awesome_print/blob/master/lib/awesome_print/formatter.rb#L109-L124
this method calls method(:to_hash)
and that causes the exception in Stripe::StripeObject
in add_accessors. I can't tell why calling .method(:to_hash)
would result in a call to add_accessors
, just yet.
This is certainly an issue w/ Stripe's metaprogramming in Stripe::StripeObject
, it's not a problem with awesome_print.
https://github.com/stripe/stripe-ruby/blob/master/lib/stripe/stripe_object.rb#L232-L259
In the meantime you could call to_hash
directly and ap transfer.to_hash
which will serve as a workaround. I've tested locally.
Ok, I think I figured it out.
Stripe::Transfer has a method
attribute. See here: Transfer#method
The Stripe::StripeObject class is a neat little metaprogrammed thing that takes a hash as input then automatically adds accessors for each of the attributes of the hash, in a nested fashion.
Sadly, though, method
is a default method on every Ruby object, so their choosing method
as an attribute of Stripe::Transfer causes a conflict.
Awesome print just so happens to rely on the method
method to work as expected, and Stripe's API breaks it. This issue should be opened on the Stripe gem's Github with a link back here for reference.
Really interesting findings @jakeonrails thanks for looking into it. I'll make that issue at Stripe and link back as you suggested.
Closing as dupe of stripe/stripe-ruby#524