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.



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

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

  @proc     = proc?
  @callable = callable?
  @method   = method?

  return if options.has_key?(:dynamic)

  @dynamic = @proc || @callable || @method
end

Instance Method Details

#dynamic?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/uber/options.rb', line 63

def dynamic?
  @dynamic
end

#evaluate(context, *args) ⇒ Object



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

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

  evaluate_for(context, *args)
end