Class: Subroutine::Outputs::LazyExecutor
- Inherits:
-
Object
- Object
- Subroutine::Outputs::LazyExecutor
- Defined in:
- lib/subroutine/outputs.rb
Instance Method Summary collapse
- #executed? ⇒ Boolean
-
#initialize(value) ⇒ LazyExecutor
constructor
A new instance of LazyExecutor.
- #value ⇒ Object
Constructor Details
#initialize(value) ⇒ LazyExecutor
Returns a new instance of LazyExecutor.
14 15 16 17 |
# File 'lib/subroutine/outputs.rb', line 14 def initialize(value) @value_block = value @executed = false end |
Instance Method Details
#executed? ⇒ Boolean
26 27 28 |
# File 'lib/subroutine/outputs.rb', line 26 def executed? @executed end |
#value ⇒ Object
19 20 21 22 23 24 |
# File 'lib/subroutine/outputs.rb', line 19 def value return @value if @executed @value = @value_block.respond_to?(:call) ? @value_block.call : @value @executed = true @value end |