Module | Memoizable
In: | lib/supplemental/facets/memoizable.rb

Memoization is an optimization technique used primarily to speed up programs by having function calls avoid repeating the calculation of results for previously-processed inputs.

When you "memoize" a method/function using Memoizable its results are cached so that later calls return results from the cache instead of recalculating them.

      class T
        include Memoizable

        def initialize(a)
          @a = a
        end

        def a
          "#{@a ^ 3 + 4}"
        end

        memoize :a
      end

      t = T.new(10)
      (t.a.__id__ == t.a.__id__)  #=> true

This method can also be used at the instance level to cache singleton (qua class) methods by including it in the singleton class.

### Methods

append_features cache memoize rememoize unmemoize

### Classes and Modules

Module Memoizable::Copy

### Public Class methods

append_features(base)
cache()

### Public Instance methods

memoize(*method_names)

Directive for making your functions faster by trading space for time. When you "memoize" a method/function using memoize its results are cached so that later calls with the same arguments return results from the cache instead of recalculating them.

The memoize method also handles a few options to alter behavior of the memoization:

      :class     => true      cache per-class not per-object
      :freeze    => true      freeze the memoized return values
      :arguments => false     do not index cache by arguments

rememoize(*method_names)

Remove the memoized value from the memoization cache. The next time a memoized methos is called if will be remomoized.

unmemoize(*method_names)

[Validate]