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

Returns a new instance of Value.



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

def initialize(value, options={})
  @value, @options = value, options

  return if @options.has_key?(:dynamic)

  # conventional behaviour:
  @callable = @options[:dynamic] = true if @value.kind_of?(Proc)
  @options[:dynamic] = true             if @value.is_a?(Symbol)
end

Instance Method Details

#dynamic?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/uber/options.rb', line 59

def dynamic?
  @options[:dynamic]
end

#evaluate(context, *args) ⇒ Object



53
54
55
56
57
# File 'lib/uber/options.rb', line 53

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

  evaluate_for(context, *args)
end