class Tzispa::Annotations::Builtin::Memoize

Public Class Methods

new() click to toggle source
# File lib/tzispa/annotations/builtin/memoize.rb, line 7
def initialize
  @cache ||= {}
end

Public Instance Methods

call(method, *args, &block) click to toggle source
# File lib/tzispa/annotations/builtin/memoize.rb, line 11
def call(method, *args, &block)
  current_cache = @cache[method.receiver] ||= {}
  return current_cache[args] if current_cache.key? args
  current_cache[args] = method.call(*args, &block)
end