Class: Uber::Options::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/uber/options.rb

Overview

TODO: rename to Value.

Instance Method Summary collapse

Constructor Details

#initialize(value, options = {}) ⇒ Value



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/uber/options.rb', line 43

def initialize(value, options={})
  @value, @dynamic = value, options[:dynamic]

  @callable = true if @value.kind_of?(Proc)

  return if options.has_key?(:dynamic)

  # conventional behaviour:
  @dynamic = true if @callable
  @dynamic = true if @value.is_a?(Symbol)
end

Instance Method Details

#dynamic?Boolean



61
62
63
# File 'lib/uber/options.rb', line 61

def dynamic?
  @dynamic
end

#evaluate(context, *args) ⇒ Object



55
56
57
58
59
# File 'lib/uber/options.rb', line 55

def evaluate(context, *args)
  return @value unless dynamic?

  evaluate_for(context, *args)
end