class Chef::Decorator::Lazy
Lazy
wrapper to delay construction of an object until a method is called against the object.
@example
def foo puts "allocated" "value" end a = Chef::Decorator::Lazy.new { foo } puts "started" a puts "still lazy" puts a outputs: started still lazy allocated value
@since 12.10.x
Public Class Methods
new(&block)
click to toggle source
Calls superclass method
Chef::Decorator::new
# File lib/chef/decorator/lazy.rb, line 48 def initialize(&block) super @block = block end
Public Instance Methods
__getobj__()
click to toggle source
Calls superclass method
# File lib/chef/decorator/lazy.rb, line 53 def __getobj__ __setobj__(@block.call) unless defined?(@delegate_sd_obj) super end