Created
February 9, 2015 14:06
-
-
Save aep/d18ab6293d865a7aa61c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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