From: Daniel DeLorme Date: 2007-02-10T13:17:42+09:00 Subject: Re: Your favorite bit of ruby code? Carl Lerche wrote: > I'd like to see some of them! This is one I particulary like from my personal library. It allows me to do stuff like: book.author.ergo.name instead of: book.author && book.author.name require "singleton" class BlackHole include Singleton private def method_missing(*args); nil; end for m in public_instance_methods undef_method(m.to_sym) unless m =~ /^__.*__$/ end end class NilClass def ergo BlackHole.instance end end class Object def ergo if block_given? yield(self) else self end end end