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

Sending :binding message to decorator returns invalid value #<Binding:0x007fef4eb2f8a0> #510

Closed
chifung7 opened this issue Apr 4, 2013 · 4 comments

Comments

@chifung7
Copy link

chifung7 commented Apr 4, 2013

Product class has an attribute named "binding". Product.new.binding is nil, so Product.new.decorate.send(:binding) should return nil but returns junk #Binding:0x007fef4eb2f8a0 instead.

After running Product.new.decorate.binding, Product.new.decorate.send(:binding) would return the correct value.

[6] pry(main)> Product.new.decorate.send(:binding)
=> #<Binding:0x007fef4eb2f8a0>
[7] pry(main)> Product.new.decorate.send(:binding)
=> #<Binding:0x007fef4ea82b50>
[8] pry(main)> Product.new.decorate.binding
=> nil
[9] pry(main)> Product.new.send(:binding)
=> nil
[10] pry(main)> Product.new.decorate.binding
=> nil
[11] pry(main)> Product.new.decorate.send(:binding)
=> nil
@steveklabnik
Copy link
Member

binding is a Ruby term, it's gonna cause conflicts that are out of our control. http://www.ruby-doc.org/core-2.0/Kernel.html#method-i-binding

@steveklabnik
Copy link
Member

(that said, if we can do it without interfering with Kernel#binding, please let me know. I'd take a patch.)

@haines
Copy link
Contributor

haines commented Apr 5, 2013

@chifung7 If you use public_send rather than send you won't have this problem!

@chifung7
Copy link
Author

chifung7 commented Apr 5, 2013

@haines Thanks for the solution!

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