On Thu, Feb 4, 2010 at 8:05 AM, Fredrik Johansson <fredjoha / gmail.com> wrote: >> You can do this with a Hash already: > > Sure (I learned that from Ruby Best Practices. great book!), but I > would like to argue that it's a bit more tidy to define a class (a > subclass of MethodHash) in one place, which I can then reuse for > anything I need to. But I don't claim to have revolutionized the world > with this. :) Doing so introduces an inheritance relationship, which is rarely a good thing in Ruby. You might want to check out the link Robert suggested, for memoize. http://raa.ruby-lang.org/project/memoize/ It also handles file based caching and is one idiomatic way of doing what you're trying to do here. -greg