-1 for the merge.
+1 for a doc fix where this is more explicit.

I've always used x.becomes(Foo) for the side effect (mutating x)
instead of for the return value.

As I see it, the name _becomes_ clearly states that the receiver is
affected. If it was #convert or #cast or something that would
reasonably return a new object while not mutating the receiver I could
see how this could be thought of as a bug.

But it just makes sense that #becomes alters the original object.

Cheers,
-foca


On Fri, Jul 20, 2012 at 11:22 PM, Dheeraj Kumar
<a.dheeraj.ku...@gmail.com> wrote:
> Got bit by this a couple of weeks ago. +1 for the merge.
>
>
> Dheeraj Kumar
>
> On Saturday 21 July 2012 at 6:14 AM, Peter Brown wrote:
>
> Just stumbled upon a pull request from last year with some discussion and it
> seemed like people were generally in favor of changing the behavior. I'd be
> willing to bring it back to life if people are still interested in it.
>
> On Friday, July 20, 2012 6:45:31 PM UTC-4, Matt jones wrote:
>
>
> On Jul 20, 2012, at 5:48 PM, Peter Brown wrote:
>
>> I ran into an interesting issue today with ActiveRecord's becomes method
>> and discovered that it is mutating the receiver without me knowing it.
>>
>> The API docs say
>>
>> "The new instance will share a link to the same attributes as the original
>> class. So any change to the attributes in either instance will affect the
>> other."
>>
>> However, it doesn't say that the type attribute is changed on the receiver
>> just by the method call.
>
> 'type' is an attribute; it gets changed - and the docs say the changes will
> happen to both. A bit unclear, but not a bug.
>
> Definitely worth an update to the documentation, though.
>
> --Matt Jones
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-core/-/22M16_XMSnYJ.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-core+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-core?hl=en.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-core+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-core?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to