class ASF::LazyHash
a hash of attributes which is not populated until the first attempt to reference a value
Public Class Methods
Source
# File lib/whimsy/asf/ldap.rb, line 578 def initialize(&initializer) super() {} @initializer = initializer end
capture an initializer to be called only if necessary.
Calls superclass method
Public Instance Methods
Source
# File lib/whimsy/asf/ldap.rb, line 586 def [](key) result = super if not result and not keys.include? key and @initializer merge! @initializer.call || {} @initializer = nil result = super end result end
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