Class: Toil::DynamicValue
- Inherits:
-
Object
- Object
- Toil::DynamicValue
- Defined in:
- lib/toil/dynamic_value.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(value = nil, &blk) ⇒ DynamicValue
constructor
A new instance of DynamicValue.
- #static? ⇒ Boolean
Constructor Details
#initialize(value = nil, &blk) ⇒ DynamicValue
Returns a new instance of DynamicValue.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/toil/dynamic_value.rb', line 5 def initialize(value = nil, &blk) @static = false @proc = if block_given? blk elsif value.is_a?(Proc) value else @static = true proc { value } end end |
Instance Method Details
#call ⇒ Object
18 19 20 |
# File 'lib/toil/dynamic_value.rb', line 18 def call @proc.call end |
#static? ⇒ Boolean
22 23 24 |
# File 'lib/toil/dynamic_value.rb', line 22 def static? @static end |