Class: Chef::Decorator::Lazy
- Inherits:
-
Chef::Decorator
- Object
- SimpleDelegator
- Chef::Decorator
- Chef::Decorator::Lazy
- Defined in:
- lib/chef/decorator/lazy.rb
Overview
Lazy wrapper to delay construction of an object until a method is called against the object.
outputs:
started
still lazy
allocated
value
Direct Known Subclasses
Instance Method Summary collapse
- #__getobj__ ⇒ Object
-
#initialize(&block) ⇒ Lazy
constructor
A new instance of Lazy.
Methods inherited from Chef::Decorator
#__setobj__, #is_a?, #kind_of?, #method_missing, #nil?
Constructor Details
#initialize(&block) ⇒ Lazy
Returns a new instance of Lazy.
48 49 50 51 |
# File 'lib/chef/decorator/lazy.rb', line 48 def initialize(&block) super @block = block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Chef::Decorator
Instance Method Details
#__getobj__ ⇒ Object
53 54 55 56 |
# File 'lib/chef/decorator/lazy.rb', line 53 def __getobj__ __setobj__(@block.call) unless defined?(@delegate_sd_obj) super end |