Module: MethodCache::ModuleExtensions

Included in:
Module
Defined in:
lib/methodcache.rb

Instance Method Summary collapse

Instance Method Details

#class_cache(name, options = {}) ⇒ Object



64
65
66
67
68
# File 'lib/methodcache.rb', line 64

def class_cache name, options = {}
  metaclass = (class<<self;self;end)
  cache = MethodCache.new(metaclass, name, :singleton, options)
  metaclass.send(:define_method, name, &cache)
end

#instance_cache(name, options = {}) ⇒ Object



56
57
58
# File 'lib/methodcache.rb', line 56

def instance_cache name, options = {}
  define_method(name, &MethodCache.new(self, name, :instance, options))
end

#module_cache(name, options = {}) ⇒ Object



70
71
72
73
# File 'lib/methodcache.rb', line 70

def module_cache name, options = {}
  class_cache name, options
  singleton_cache name, options
end

#singleton_cache(name, options = {}) ⇒ Object Also known as: cache



60
61
62
# File 'lib/methodcache.rb', line 60

def singleton_cache name, options = {}
  define_method(name, &MethodCache.new(self, name, :singleton, options))
end