Module: MethodCache::ModuleExtensions
- Included in:
- Module
- Defined in:
- lib/methodcache.rb
Instance Method Summary collapse
- #class_cache(name, options = {}) ⇒ Object
- #instance_cache(name, options = {}) ⇒ Object
- #module_cache(name, options = {}) ⇒ Object
- #singleton_cache(name, options = {}) ⇒ Object (also: #cache)
Instance Method Details
#class_cache(name, options = {}) ⇒ Object
64 65 66 67 68 |
# File 'lib/methodcache.rb', line 64 def class_cache name, = {} = (class<<self;self;end) cache = MethodCache.new(, name, :singleton, ) .send(:define_method, name, &cache) end |
#instance_cache(name, options = {}) ⇒ Object
56 57 58 |
# File 'lib/methodcache.rb', line 56 def instance_cache name, = {} define_method(name, &MethodCache.new(self, name, :instance, )) end |
#module_cache(name, options = {}) ⇒ Object
70 71 72 73 |
# File 'lib/methodcache.rb', line 70 def module_cache name, = {} class_cache name, singleton_cache name, end |
#singleton_cache(name, options = {}) ⇒ Object Also known as: cache
60 61 62 |
# File 'lib/methodcache.rb', line 60 def singleton_cache name, = {} define_method(name, &MethodCache.new(self, name, :singleton, )) end |