Class: Manana
- Inherits:
-
Object
- Object
- Manana
- Defined in:
- lib/manana.rb,
lib/manana/version.rb
Overview
Manana lets you defer the initialization of an object until its methods are called.
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.deferred_init(&initialization_block) ⇒ Manana
wraps an initialization block so that it can be deferred to a later time when object methods are called.
Instance Method Summary collapse
-
#method_missing(method, *args, &block) ⇒ Object
passes any method call through to the wrapped object after ensuring that the initialization block has successfully completed once (setting a valid instance of the object).
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Note:
Once the initialization block succeeds, it keeps the resulting object instance for subsequent method calls.
passes any method call through to the wrapped object after ensuring that the initialization block has successfully completed once (setting a valid instance of the object).
40 41 42 43 |
# File 'lib/manana.rb', line 40 def method_missing(method, *args, &block) instance = safe_get_instance instance.send(method, *args, &block); end |