<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Chris Kite &#187; Ruby</title>
	<atom:link href="http://www.chriskite.com/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chriskite.com</link>
	<description>Programming, Computer Security, Etc.</description>
	<lastBuildDate>Wed, 24 Jun 2009 02:28:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Handy Ruby Gem: andand</title>
		<link>http://www.chriskite.com/2009/04/08/handy-ruby-gem-andand/</link>
		<comments>http://www.chriskite.com/2009/04/08/handy-ruby-gem-andand/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 00:30:18 +0000</pubDate>
		<dc:creator>Chris Kite</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.chriskite.com/?p=32</guid>
		<description><![CDATA[I came across a really useful Ruby gem today: andand.  In PHP web development, I usually use this idiom when retrieving an object from the database model:

$obj = $model-&#62;getObject($id);
if(null !== $obj) {
    doSomething($obj);
}

Obviously this is a little cumbersome, since I have to do this every single time I get an object [...]]]></description>
			<content:encoded><![CDATA[<p>I came across a really useful Ruby gem today: <a href="http://andand.rubyforge.org/" target="_blank">andand</a>.  In PHP web development, I usually use this idiom when retrieving an object from the database model:</p>
<pre class="brush: php;">
$obj = $model-&gt;getObject($id);
if(null !== $obj) {
    doSomething($obj);
}
</pre>
<p>Obviously this is a little cumbersome, since I have to do this every single time I get an object using a function that might return <em>null</em>. Reginald Braithwaite, author of andand, has made this process a heck of a lot easier for all the Rubyists out there. His gem allows natural method chaining for functions that can return <em>nil</em>:</p>
<pre class="brush: ruby; light: true;">@phone = Location.find(:first, ...elided... ).andand.phone</pre>
<p>This saves a lot of boilerplate code and improves readability. I like it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chriskite.com/2009/04/08/handy-ruby-gem-andand/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
