module EventMachine::Deferrable
def self.future arg, cb=nil, eb=nil, &blk
use the supplied block (if any) as the callback.
are defined, then use them. If neither are defined, then
then look at the arguments. If either callback or errback
If arg is deferrable (responds to :set_deferred_status),
If arg is an ordinary expression, then return it.
What's the class of arg?
Evaluate arg (which may be an expression or a block).
--
A future is a sugaring of a typical deferrable usage.
def self.future arg, cb=nil, eb=nil, &blk arg = arg.call if arg.respond_to?(:call) if arg.respond_to?(:set_deferred_status) if cb || eb arg.callback(&cb) if cb arg.errback(&eb) if eb else arg.callback(&blk) if blk end end arg end