class ASF::LazyHash

a hash of attributes which is not populated until the first attempt to reference a value

Public Class Methods

new(&initializer) click to toggle source

capture an initializer to be called only if necessary.

# File lib/whimsy/asf/ldap.rb, line 537
def initialize(&initializer)
  @initializer = initializer

Public Instance Methods

[](key) click to toggle source

if referencing a key that is not in the hash, and the initializer has not yet been called, call the initializer, merge the results, and try again.

Calls superclass method
# File lib/whimsy/asf/ldap.rb, line 544
def [](key)
  result = super
  if not result and not keys.include? key and @initializer
    merge! || {}
    @initializer = nil
    result = super