Class: Curry::LazySpice
Overview
Special spice that calls out to a block to get it’s argument. The block is called each time an argument is required. Unlike the other spices, this must be instantiated with the block you want lazily evaluated.
Instance Method Summary collapse
-
#initialize(&promise) ⇒ LazySpice
constructor
A new instance of LazySpice.
-
#spice_arg(args) ⇒ Object
called to provide the missing argument.
Methods inherited from SpiceArg
Constructor Details
#initialize(&promise) ⇒ LazySpice
Returns a new instance of LazySpice.
121 122 123 124 |
# File 'lib/curry.rb', line 121 def initialize( &promise ) super("LAZYSPICE") @promise = promise end |
Instance Method Details
#spice_arg(args) ⇒ Object
called to provide the missing argument
126 127 128 |
# File 'lib/curry.rb', line 126 def spice_arg( args ) # called to provide the missing argument [@promise.call(args)] end |