Google Groups Home
Help | Sign in
Message from discussion .each { |m| delegate m, :to => :published_at }
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Duane Johnson  
View profile
 More options Jan 1 2007, 11:43 am
From: Duane Johnson <duane.john...@gmail.com>
Date: Mon, 1 Jan 2007 09:43:04 -0700
Local: Mon, Jan 1 2007 11:43 am
Subject: Re: [Rails] Re: .each { |m| delegate m, :to => :published_at }
Thanks, Tom, that's really handy.

I was wondering where this 'delegate' method is defined, so I looked  
it up and found it in ActiveSupport--it's a method defined in the  
Module class.  Pretty tricky :)

Available here, if anyone else is interested:
   activesupport/lib/active_support/core_ext/module/delegation.rb

Duane Johnson
(canadaduane)
http://blog.inquirylabs.com/

On Jan 1, 2007, at 12:52 AM, Tom Fakes wrote:

> This is the quick way of writing the following:

>  def year
>    published_at.year
>  end

>  def year=(y)
>    published_at.year = y
>  end

>  # Same for month and day

> The 'delegate' method allows you to delegate a member access to a
> member with the same name on a different member object, so you can
> avoid writing 'content.published_at.year'


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google