Class: Uber::Options::Value

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

Overview

DEPRECATED! PLEASE USE UBER::OPTION.

Instance Method Summary collapse

Constructor Details

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

TODO: rename to Value.



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/uber/options.rb', line 32

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

#call(context, *args) ⇒ Object Also known as: evaluate



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

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

  evaluate_for(context, *args)
end

#callable?Boolean

Returns:

  • (Boolean)


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

def callable?
  @value.is_a?(Uber::Callable)
end

#dynamic?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/uber/options.rb', line 51

def dynamic?
  @dynamic
end

#method?Boolean

Returns:

  • (Boolean)


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

def method?
  @value.is_a?(Symbol)
end

#proc?Boolean

Returns:

  • (Boolean)


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

def proc?
  @value.kind_of?(Proc)
end