Class: MethodDecorators::Memoize
Instance Method Summary
collapse
Methods inherited from Decorator
#+@, +@, current_decorators
Constructor Details
5
6
7
|
# File 'lib/method_decorators/memoize.rb', line 5
def initialize
@memo_ivar = "@_memoize_cache#{rand(10**10)}"
end
|
Instance Method Details
#call(orig, this, *args, &blk) ⇒ Object
9
10
11
12
|
# File 'lib/method_decorators/memoize.rb', line 9
def call(orig, this, *args, &blk)
return cache(this)[args] if cache(this).has_key?(args)
cache(this)[args] = orig.call(*args, &blk)
end
|