Locale::Util::Memoizable

Constants

MEMOIZED_IVAR

Public Class Methods

included(base) click to toggle source
    # File lib/locale/util/memoizable.rb, line 14
14:       def self.included(base)
15:         mod = self
16:         base.class_eval do
17:           extend mod
18:         end
19:       end

Public Instance Methods

memoize(*symbols) click to toggle source

Cache the result of the methods.

 include Memoizable
 def foo
   ......
 end
 def bar(a, b)
   ......
 end
 memoize :foo, :bar(a, b)

To clear cache, #, # is also defined.

(NOTE)

  • Consider to use this with huge objects to avoid memory leaks.

  • Can’t use this with super. because of infinity loop.

    # File lib/locale/util/memoizable.rb, line 55
55:       def memoize(*symbols)
56:         memoize_impl(false, *symbols)
57:       end
memoize_clear() click to toggle source

Clear memoized values.

    # File lib/locale/util/memoizable.rb, line 35
35:       def memoize_clear
36:         @_memoized_ivars = {}
37:       end
memoize_dup(*symbols) click to toggle source

memoize with dup. A copy object is returned.

    # File lib/locale/util/memoizable.rb, line 60
60:       def memoize_dup(*symbols)
61:         memoize_impl(true, *symbols)
62:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.