Class: Ting::MemoizeCall
- Inherits:
-
Object
- Object
- Ting::MemoizeCall
- Includes:
- Procable
- Defined in:
- lib/ting/memoize_call.rb
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(target) ⇒ MemoizeCall
constructor
A new instance of MemoizeCall.
Methods included from Procable
Constructor Details
#initialize(target) ⇒ MemoizeCall
Returns a new instance of MemoizeCall.
5 6 7 8 |
# File 'lib/ting/memoize_call.rb', line 5 def initialize(target) @target = target @map = {} end |
Instance Method Details
#call(*args) ⇒ Object
10 11 12 |
# File 'lib/ting/memoize_call.rb', line 10 def call(*args) @map[args] ||= @target.call(*args) end |