Module: Locale::Util::Memoizable

### Home Classes Methods

### In Files

- lib/locale/util/memoizable.rb

### Methods

- ::included
- #memoize
- #memoize_clear
- #memoize_dup

### Class/Module Index

Quicksearch

- Locale
- Locale::Driver
- Locale::Driver::CGI
- Locale::Driver::Env
- Locale::Driver::JRuby
- Locale::Driver::Posix
- Locale::Driver::Win32
- Locale::Driver::Win32::Kernel32
- Locale::Driver::Win32Table
- Locale::Info
- Locale::Info::Language
- Locale::Info::Region
- Locale::Middleware
- Locale::Tag
- Locale::Tag::Cldr
- Locale::Tag::Common
- Locale::Tag::Irregular
- Locale::Tag::Posix
- Locale::Tag::Rfc
- Locale::Tag::Simple
- Locale::TagList
- Locale::Util
- Locale::Util::Memoizable

No matching classes.

# Locale::Util::Memoizable

### Constants

MEMOIZED_IVAR

### Public Class Methods

included(base) click to toggle source

    # File lib/locale/util/memoizable.rb, line 14
    def self.included(base)
      mod = self
      base.class_eval do
        extend mod
      end
    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, clear_foo, clear_bar is also defined.

(NOTE)

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

- Can't use this with super.<method> because of infinity loop.

    # File lib/locale/util/memoizable.rb, line 55
    def memoize(*symbols)
      memoize_impl(false, *symbols)
    end

memoize_clear() click to toggle source

Clear memoized values.

    # File lib/locale/util/memoizable.rb, line 35
    def memoize_clear
      @_memoized_ivars = {}
    end

memoize_dup(*symbols) click to toggle source

memoize with dup. A copy object is returned.

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.