Class: MethodDecorators::Memoize

Inherits:
Decorator show all
Defined in:
lib/method_decorators/memoize.rb

Instance Method Summary collapse

Methods inherited from Decorator

#+@, +@, current_decorators

Instance Method Details

#call(orig, this, *args, &blk) ⇒ Object



5
6
7
8
# File 'lib/method_decorators/memoize.rb', line 5

def call(orig, this, *args, &blk)
  return cache(this)[args] if cache(this).has_key?(args)
  cache(this)[args] = orig.call(*args, &blk)
end