Skip to content

Instantly share code, notes, and snippets.

@aep
Created February 9, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aep/d18ab6293d865a7aa61c to your computer and use it in GitHub Desktop.
Save aep/d18ab6293d865a7aa61c to your computer and use it in GitHub Desktop.
class Foo
def a
4
end
def self.cached(key, &block)
define_method key.to_s do
self.a + yield
end
end
cached :foo do
3
end
cached :swag do
foo
end
end
f = Foo.new
p f.swag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment