<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Understanding Ruby and Rails: Delegate</title>
	<atom:link href="http://www.simonecarletti.com/blog/2009/12/inside-ruby-on-rails-delegate/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.simonecarletti.com/blog/2009/12/inside-ruby-on-rails-delegate/</link>
	<description>Simone Carletti&#039;s personal ramblings on programming, syndication, search engines &#38; marketing.</description>
	<lastBuildDate>Thu, 09 Feb 2012 14:24:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Yan Cherfan</title>
		<link>http://www.simonecarletti.com/blog/2009/12/inside-ruby-on-rails-delegate/#comment-40474</link>
		<dc:creator>Yan Cherfan</dc:creator>
		<pubDate>Sun, 04 Dec 2011 16:07:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=794#comment-40474</guid>
		<description>Very useful post. Thanks!</description>
		<content:encoded><![CDATA[<p>Very useful post. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bra1n</title>
		<link>http://www.simonecarletti.com/blog/2009/12/inside-ruby-on-rails-delegate/#comment-38793</link>
		<dc:creator>bra1n</dc:creator>
		<pubDate>Tue, 20 Sep 2011 10:51:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=794#comment-38793</guid>
		<description>def ma,e
    # let&#039;s use try to bypass nil-check
    user.try(:name)
  end

seems like a typo, too...? Or did you indeed mean &quot;ma,e&quot; instead of &quot;name&quot;?</description>
		<content:encoded><![CDATA[<p>def ma,e<br />
    # let&#8217;s use try to bypass nil-check<br />
    user.try(:name)<br />
  end</p>
<p>seems like a typo, too&#8230;? Or did you indeed mean &#8220;ma,e&#8221; instead of &#8220;name&#8221;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simone Carletti</title>
		<link>http://www.simonecarletti.com/blog/2009/12/inside-ruby-on-rails-delegate/#comment-36933</link>
		<dc:creator>Simone Carletti</dc:creator>
		<pubDate>Thu, 11 Aug 2011 20:45:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=794#comment-36933</guid>
		<description>You&#039;re right, there&#039;s a typo. To keep it simple, I changed the first example to assume the method to be invoked is called &lt;code&gt;author&lt;/code&gt;.
Thanks for pointing it out. :)</description>
		<content:encoded><![CDATA[<p>You&#8217;re right, there&#8217;s a typo. To keep it simple, I changed the first example to assume the method to be invoked is called <code>author</code>.<br />
Thanks for pointing it out. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fearless fool</title>
		<link>http://www.simonecarletti.com/blog/2009/12/inside-ruby-on-rails-delegate/#comment-36932</link>
		<dc:creator>fearless fool</dc:creator>
		<pubDate>Thu, 11 Aug 2011 20:13:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=794#comment-36932</guid>
		<description>I&#039;m a little late to the party, but I don&#039;t understand how the first example of delegation works:

    class Post
      belongs_to :user
      delegate :author, :to =&gt; :user, :allow_nil =&gt; true
    end

Either there&#039;s a typo, or User magically knows that :author really means to invoke the :name method, or I&#039;m missing something fundamental.  I&#039;m hoping its the former.  Clarification?</description>
		<content:encoded><![CDATA[<p>I&#8217;m a little late to the party, but I don&#8217;t understand how the first example of delegation works:</p>
<p>    class Post<br />
      belongs_to :user<br />
      delegate :author, :to =&gt; :user, :allow_nil =&gt; true<br />
    end</p>
<p>Either there&#8217;s a typo, or User magically knows that :author really means to invoke the :name method, or I&#8217;m missing something fundamental.  I&#8217;m hoping its the former.  Clarification?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rubyu2</title>
		<link>http://www.simonecarletti.com/blog/2009/12/inside-ruby-on-rails-delegate/#comment-15803</link>
		<dc:creator>rubyu2</dc:creator>
		<pubDate>Sat, 09 Oct 2010 08:37:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=794#comment-15803</guid>
		<description>i agree that the &#039;post.new.user.name&#039; style.
but sometime i will write a method like that &#039;def user_name self.user.name end&#039; if use user_name offen.</description>
		<content:encoded><![CDATA[<p>i agree that the &#8216;post.new.user.name&#8217; style.<br />
but sometime i will write a method like that &#8216;def user_name self.user.name end&#8217; if use user_name offen.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: A Rubyist&#8217;s Beautiful Mistress: method_missing &#045; Alfa Jango Blog</title>
		<link>http://www.simonecarletti.com/blog/2009/12/inside-ruby-on-rails-delegate/#comment-15801</link>
		<dc:creator>A Rubyist&#8217;s Beautiful Mistress: method_missing &#045; Alfa Jango Blog</dc:creator>
		<pubDate>Fri, 08 Oct 2010 20:10:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=794#comment-15801</guid>
		<description>[...] you take what you can get. If you want more readable code, check out ruby delegation library and Rails ActiveRecord delegation.  So, let&#8217;s put this all together to see the real power of define_method. This is adapted [...]</description>
		<content:encoded><![CDATA[<p>[...] you take what you can get. If you want more readable code, check out ruby delegation library and Rails ActiveRecord delegation.  So, let&#8217;s put this all together to see the real power of define_method. This is adapted [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn R</title>
		<link>http://www.simonecarletti.com/blog/2009/12/inside-ruby-on-rails-delegate/#comment-11913</link>
		<dc:creator>Glenn R</dc:creator>
		<pubDate>Tue, 01 Jun 2010 08:40:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=794#comment-11913</guid>
		<description>Hi Kally

I agree that the &#039;Post.new.user.name&#039; style of doing things can be more natural and readable, but it may be a sign of coupling in your app. 

There&#039;s a good discussion of it here: http://haacked.com/archive/2009/07/14/law-of-demeter-dot-counting.aspx

I try to always keep in mind that those long chained method calls are a bit of a code smell, and to consider a refactor with delegate() if it makes sense.</description>
		<content:encoded><![CDATA[<p>Hi Kally</p>
<p>I agree that the &#8216;Post.new.user.name&#8217; style of doing things can be more natural and readable, but it may be a sign of coupling in your app. </p>
<p>There&#8217;s a good discussion of it here: <a href="http://haacked.com/archive/2009/07/14/law-of-demeter-dot-counting.aspx" rel="nofollow">http://haacked.com/archive/2009/07/14/law-of-demeter-dot-counting.aspx</a></p>
<p>I try to always keep in mind that those long chained method calls are a bit of a code smell, and to consider a refactor with delegate() if it makes sense.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Understanding Ruby and Rails: Proxy Patter, Dynamic Delegation and BasicObject &#8211; Simone Carletti&#39;s Blog</title>
		<link>http://www.simonecarletti.com/blog/2009/12/inside-ruby-on-rails-delegate/#comment-11391</link>
		<dc:creator>Understanding Ruby and Rails: Proxy Patter, Dynamic Delegation and BasicObject &#8211; Simone Carletti&#39;s Blog</dc:creator>
		<pubDate>Thu, 13 May 2010 07:57:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=794#comment-11391</guid>
		<description>[...] For the most part of Ruby code, this change won&#8217;t mean anything special. However the BasicObject plays a fundamental role to implement the proxy pattern and dynamic delegation. [...]</description>
		<content:encoded><![CDATA[<p>[...] For the most part of Ruby code, this change won&#8217;t mean anything special. However the BasicObject plays a fundamental role to implement the proxy pattern and dynamic delegation. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kally</title>
		<link>http://www.simonecarletti.com/blog/2009/12/inside-ruby-on-rails-delegate/#comment-7785</link>
		<dc:creator>Kally</dc:creator>
		<pubDate>Tue, 12 Jan 2010 16:10:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=794#comment-7785</guid>
		<description>I&#039;m probably wrong, but I feel like this is more useful with non-activerecord classes, although most people think the exact opposite.
For example, if I want to write
Post.new.user_name, it makes more sense to me to write Post.new.user.name, same number of characters, but it is more clear what&#039;s happening, without any quasi-virtual attribute.
Interesting anyway the technique in general.
Thanks.</description>
		<content:encoded><![CDATA[<p>I&#8217;m probably wrong, but I feel like this is more useful with non-activerecord classes, although most people think the exact opposite.<br />
For example, if I want to write<br />
Post.new.user_name, it makes more sense to me to write Post.new.user.name, same number of characters, but it is more clear what&#8217;s happening, without any quasi-virtual attribute.<br />
Interesting anyway the technique in general.<br />
Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brainopia</title>
		<link>http://www.simonecarletti.com/blog/2009/12/inside-ruby-on-rails-delegate/#comment-6835</link>
		<dc:creator>brainopia</dc:creator>
		<pubDate>Tue, 15 Dec 2009 20:38:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.simonecarletti.com/blog/?p=794#comment-6835</guid>
		<description>Don&#039;t forget to mention forwardable.</description>
		<content:encoded><![CDATA[<p>Don&#8217;t forget to mention forwardable.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

