@Jon: I've updated my patch at https://github.com/rails/rails/pull/2733/files
The new version should play well with []= methods. If the change is accepted I will be perfectly willing to implement a deprecation patch for 3.1. Should I begin now, or is the issue still contested? Cheers, Daniel Schierbeck On Mon, Aug 29, 2011 at 2:42 PM, Jon Leighton <[email protected]> wrote: > On Mon, 2011-08-29 at 14:16 +0200, Daniel Schierbeck wrote: >> @Jon: I could change the implementation to check `args.length` and >> raise ArgumentError if the result is greater than 1. But wouldn't it >> suffice to simply define the writer methods with only one argument? > > Yes, that's what I meant. > > We need a patch against 3-1-stable that: > > * Calls @target.foo, rescues NoMethodError, tries @target.__send__(:foo) > and if that works, shows a deprecation warning. (The reason for this > implementation is that there should be no performance hit in the public > case.) > * Shows a deprecation warning if args.length > 1 && > method_name.ends_with?('=') > > Then, we need the patch against master to just define def foo=(bar) (no > splat), when method_name.ends_with?('='). > > If the deprecation in 3-1-stable is too involved, we might need to think > about deprecating in 3.2 and removing in 3.3. But let's see the code > first. Also note that this deprecation won't get into 3.1.0, so it would > be a new deprecation in 3.1.1. (Some may object to this, but I think > it's acceptable personally.) > >> @Xavier: I think users perceive `delegate` as a shorthand for: >> >> def foo >> @target.foo >> end >> >> and not >> >> def foo >> @target.__send__(:foo) >> end >> >> so I actually believe the proposed semantics more closely resembles >> the perception. That's just my point of view, of course. > > Yes, this is my perspective as well. To me the POLS is that 'delegate' > is a macro for the former, which does not support non-public methods. > > -- > http://jonathanleighton.com/ > -- Med venlig hilsen Daniel Schierbeck -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
