Class: Toil::DynamicValue

Inherits:
Object
  • Object
show all
Defined in:
lib/toil/dynamic_value.rb

Instance Method Summary collapse

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

#callObject



18
19
20
# File 'lib/toil/dynamic_value.rb', line 18

def call
  @proc.call
end

#static?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/toil/dynamic_value.rb', line 22

def static?
  @static
end