class Uber::Options::Value
DEPRECATED! PLEASE USE UBER::OPTION.
Public Class Methods
Source
# 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
Public Instance Methods
Source
# File lib/uber/options.rb, line 44 def call(context, *args) return @value unless dynamic? evaluate_for(context, *args) end
Also aliased as: evaluate
Source
# File lib/uber/options.rb, line 59 def callable? @value.is_a?(Uber::Callable) end
Private Instance Methods
Source
# File lib/uber/options.rb, line 88 def callable!(context, *args) @value.call(context, *args) end
Callable
object is executed in its original context.
Source
# File lib/uber/options.rb, line 68 def evaluate_for(*args) return proc!(*args) if @proc return callable!(*args) if @callable method!(*args) # TODO: change to context.instance_exec and deprecate first argument. end
Source
# File lib/uber/options.rb, line 75 def method!(context, *args) context.send(@value, *args) end
Source
# File lib/uber/options.rb, line 79 def proc!(context, *args) if context.nil? @value.call(*args) else context.instance_exec(*args, &@value) end end