module Memoizable::InstanceMethods
Methods mixed in to memoizable instances
Public Instance Methods
freeze()
click to toggle source
Freeze the object
@example
object.freeze # object is now frozen
@return [Object]
@api public
Calls superclass method
# File lib/memoizable/instance_methods.rb, line 15 def freeze memoized_method_cache # initialize method cache super end
memoize(data)
click to toggle source
Sets a memoized value for a method
@example
object.memoize(hash: 12345)
@param [Hash{Symbol => Object}] data
the data to memoize
@return [self]
@api public
# File lib/memoizable/instance_methods.rb, line 31 def memoize(data) data.each { |name, value| memoized_method_cache[name] = value } self end
Private Instance Methods
memoized_method_cache()
click to toggle source
The memoized method results
@return [Hash]
@api private
# File lib/memoizable/instance_methods.rb, line 43 def memoized_method_cache @_memoized_method_cache ||= Memory.new end