Sha256: f8ac7a92aefb051f602c0efc9d01af5e4f6313b159d91e96baedcaa8734d92e9
Contents?: true
Size: 430 Bytes
Versions: 1
Compression:
Stored size: 430 Bytes
Contents
module RubyMemoized class Memoizer attr_reader :context, :method def initialize(context, method) @context = context @method = method end 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 def cache @cache ||= {} end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby_memoized-0.1.3 | lib/ruby_memoized/memoizer.rb |