class RubyMemoized::Memoizer

Attributes

context[R]
method[R]

Public Class Methods

new(context, method) click to toggle source
# File lib/ruby_memoized/memoizer.rb, line 5
def initialize(context, method)
  @context = context
  @method = method
end

Public Instance Methods

cache() click to toggle source
# File lib/ruby_memoized/memoizer.rb, line 15
def cache
  @cache ||= {}
end
call(*args, **kwargs, &block) click to toggle source
# File lib/ruby_memoized/memoizer.rb, line 10
def call(*args, **kwargs, &block)
  return cache[[args, kwargs, block]] if cache.has_key?([args, kwargs, block])
  cache[[args, kwargs, block]] = context.send(method, *args, **kwargs, &block)
end