-
Notifications
You must be signed in to change notification settings - Fork 526
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
Delegation of to_s to source? #560
Comments
Hi Olivier, thanks for reporting this. Basically, For ActiveModel compatibility, we needed to delegate |
Yeah, seems fine. |
Note that this makes debugging a lot more confusing since the most common way to distinguish between a decorator and its object is no longer useful. Before this change, from a
After this change:
Even calling
|
Turns out to be an unfortunate difference between Ruby 1.9 and 2.0 - it looks like the On 2.0 I get the expected result: decorator = UserDecorator.new(User.new)
decorator.to_s #=> "#<User:0x03ca1a18>"
decorator.inspect #=> "#<UserDecorator:0x03ca1978 @object=#<User:0x03ca1a18>, @context={}>" A custom |
It turns out that this is one of the "five notable incompatibilities" - from http://www.ruby-lang.org/en/news/2013/02/24/ruby-2-0-0-p0-is-released/, "Object#inspect does always return a string like #ClassName:0x… instead of delegating to #to_s. [#2152]". A whole thread is at http://bugs.ruby-lang.org/issues/show/2152. I wonder if it's possible to grab a reference to the original |
@haines Thanks again for this. |
Curious why with
delegate_all
called at the top of a Decorator I get"#<UserDecorator:0x007fd78b9dbc40>"
when callingto_s
whileto_param
properly delegates to the User class'to_param
.Any idea?
The text was updated successfully, but these errors were encountered: