Request for Review: Make it possible to prefix delegate methods

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?


Why wouldn't you just do and obj.client.address if
you're looking to keep some context in the names?

Also if you're looking for some alternate method names, wouldn't the
use of "alias" help?

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 `' 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. <>
2. <

Best regards
Daniel Schierbeck

Just want to say that I would really like that too!