Module: Adamantium::ModuleMethods

Defined in:
lib/adamantium/module_methods.rb

Overview

Methods mixed in to adamantium modules

Instance Method Summary collapse

Instance Method Details

#freezerFreezer::Deep

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:



27
28
29
# File 'lib/adamantium/module_methods.rb', line 27

def freezer
  Freezer::Deep
end

#included(mod) ⇒ self

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.

Hook called when module is included

Parameters:

  • mod (Module)

    the module including ModuleMethods

Returns:

  • (self)


16
17
18
19
# File 'lib/adamantium/module_methods.rb', line 16

def included(mod)
  Adamantium.included(mod)
  self
end

#memoize(*methods) ⇒ self

Memoize a list of methods

Examples:

memoize :hash

Parameters:

  • methods (Array<#to_s>)

    a list of methods to memoize

Returns:

  • (self)


42
43
44
45
46
47
# File 'lib/adamantium/module_methods.rb', line 42

def memoize(*methods)
  options        = methods.last.kind_of?(Hash) ? methods.pop : {}
  method_freezer = Freezer.parse(options) || freezer
  methods.each { |method| memoize_method(method, method_freezer) }
  self
end