Sha256: 250c8b7196c0ec7596a980744b0ba5f66014b9c21c3bd9a8edca1a4092e5ed9d
Contents?: true
Size: 434 Bytes
Versions: 1
Compression:
Stored size: 434 Bytes
Contents
# frozen_string_literal: true module Lite module Memoize module Klass include Lite::Memoize::Mixin def memoize(method_name, as: nil) inner_method = instance_method(method_name) define_method(method_name) do |*args| key = self.class.caller_key(args, as: as || method_name) self.class.store[key] ||= inner_method.bind(self).call(*args) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lite-memoize-1.0.1 | lib/lite/memoize/klass.rb |