The theoretic basis for the proposal stems from the Law of Demeter[1],
which basically states that you should “only talk to your immediate
friends.”, meaning that `obj.client.name' makes assumptions about the
inner structure of `client', while `obj.client_name' doesn't. A more
general Ruby discussion[2] shows how to delegate properly with the
Forwardable mixin. Since Rails uses the ActiveSupport delegation, I've
tried to implement some of the ideas there.

 1. <http://en.wikipedia.org/wiki/Law_Of_Demeter>
 2. <http://blog.jayfields.com/2006/05/law-of-demeter-and-
forwardable.html>


Best regards
Daniel Schierbeck

On Oct 12, 7:31 pm, "Andrew Kaspick" <[EMAIL PROTECTED]> wrote:
> Why wouldn't you just do obj.client.name and obj.client.address if
> you're looking to keep some context in the names?
>
> On Sat, Oct 11, 2008 at 2:06 PM, Daniel Schierbeck
>
> <[EMAIL PROTECTED]> wrote:
>
> > I've submitted a patch to Lighthouse which makes it possible to prefix
> > delegation methods, i.e.:
>
> >  delegate :name, :address, :to => :client, :prefix => true
>
> > Which would create the methods #client_name and #client_address. It's
> > also possible to give a custom prefix, e.g. :customer.
>
> > Could I get someone to take a look at this patch?
>
> >  <http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/
> > 984>
>
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to