Module: Memoizable::ModuleMethods

Includes:
Memoizable
Defined in:
lib/memoizable/module_methods.rb

Overview

Methods mixed in to memoizable singleton classes

Constant Summary

Constants included from Memoizable

Freezer, VERSION

Instance Method Summary collapse

Methods included from InstanceMethods

#freeze

Instance Method Details

#freezer ⇒ #call

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return default deep freezer

Returns:

  • (#call)


13
14
15
# File 'lib/memoizable/module_methods.rb', line 13

def freezer
  Freezer
end

#memoize(*methods) ⇒ self

Memoize a list of methods

Examples:

memoize :hash

Parameters:

  • methods (Array<Symbol>) —

    a list of methods to memoize

Returns:

  • (self)


28
29
30
31
# File 'lib/memoizable/module_methods.rb', line 28

def memoize(*methods)
  methods.each { |method| memoize_method(method) }
  self
end

#unmemoized_instance_method(name) ⇒ UnboundMethod

Return unmemoized instance method

Examples:


class Foo
  include Memoizable

  def bar
  end
  memoize :bar
end

Foo.unmemoized_instance_method(:bar)

Parameters:

  • name (Symbol)

Returns:

  • (UnboundMethod) —

    the memoized method

Raises:

  • (NameError) —

    raised if the method is unknown



56
57
58
# File 'lib/memoizable/module_methods.rb', line 56

def unmemoized_instance_method(name)
  memoized_methods[name].original_method
end