Class: Uber::Option

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

Class Method Summary collapse

Class Method Details

.[](value, options = {}) ⇒ Object

TODO: instance_exec: true



5
6
7
8
9
10
11
12
13
14
# File 'lib/uber/option.rb', line 5

def self.[](value, options={}) # TODO: instance_exec: true
  if value.is_a?(Proc)
    return ->(context, *args) { context.instance_exec(*args, &value) } if options[:instance_exec]
    return value
  end

  return value                                            if value.is_a?(Uber::Callable)
  return ->(context, *args){ context.send(value, *args) } if value.is_a?(Symbol)
  ->(*) { value }
end