For any struggling to understand Ruby's metaprogramming, the rather short and succinct <i>Metaprogramming Ruby</i> is an excellent read. There's a method to the madness of define_method, method_missing, the various eval methods, the difference between Blocks, Procs, and Lambdas. Most of it revolves around manipulating scopes.<p>It also shows how you can iterate from the ugliest, most powerful, most dangerous <i>eval</i> method by pulling out the functionality you need into less-powerful, safer manipulations. It's all Ruby code until it's actually executed, so it can all be manipulated at runtime.<p><a href="http://www.amazon.com/Metaprogramming-Ruby-Program-Like-Pros/dp/1934356476" rel="nofollow">http://www.amazon.com/Metaprogramming-Ruby-Program-Like-Pros...</a>