class ShortCircuIt::MemoizationStore
Public Class Methods
new(owner)
click to toggle source
@param owner [*] The object being memoized
# File lib/short_circu_it/memoization_store.rb, line 10 def initialize(owner) @owner = owner end
Public Instance Methods
memoize(method_name, argument_hash) { || ... }
click to toggle source
@param method_name [Symbol] The name of the method being memoized. @param argument_hash [Integer] The hash value of the arguments passed to the method. @yield [] Yields to a given block with no arguments. Memoizes the value returned by the block. @return [*] The value returned either from the memoization cache if present, or yielded block if not.
# File lib/short_circu_it/memoization_store.rb, line 18 def memoize(method_name, argument_hash) return memoized_value(method_name, argument_hash) if memoized?(method_name, argument_hash) clear_memoization(method_name) unless current_memoization_for_method?(method_name) yield.tap do |returned_value| current_memoization_for_method(method_name)[argument_hash] = returned_value end