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.
Calls superclass method
# File lib/whimsy/asf/ldap.rb, line 578 def initialize(&initializer) super() {} @initializer = initializer end
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 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