Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/uber/option.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
module Uber
class Option
def self.[](value, options={}) # TODO: instance_exec: true
if value.is_a?(Proc)
case value
when Proc
return ->(context, *args) { context.instance_exec(*args, &value) } if options[:instance_exec]
return value
value
when Uber::Callable
value
when Symbol
->(context, *args) { context.send(value, *args) }
else
->(*) { value }
end

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