Sha256: 5fb224feac204e8b0deeb3139e10d3e557bab3b91e535a42af2f8de39530a09d
Contents?: true
Size: 388 Bytes
Versions: 4
Compression:
Stored size: 388 Bytes
Contents
# frozen_string_literal: true module ActiveMemoize module Klass include ActiveMemoize::Shared def memoize(method_name, as: nil) inner_method = instance_method(method_name) define_method(method_name) do |*args| key = self.class.key(as || method_name, args) self.class.cache[key] ||= inner_method.bind(self).call(*args) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems