module EventMachine::Deferrable

def callback &block


If status is failed, do nothing.
If status is succeeded, execute the callback immediately.
If there is no status, add a callback to an internal list.
--

prior #set_deferred_status call.
block will be executed immediately, receiving the parameters given to the
If you call this method on a Deferrable whose status is :succeeded, the
will cause the callback block to be stored on an internal list.
Calling this method on a Deferrable object whose status is not yet known

a status of :succeeded. See #set_deferred_status for more information.
Specify a block to be executed if and when the Deferrable object receives
def callback &block
  return unless block
  @deferred_status ||= :unknown
  if @deferred_status == :succeeded
    block.call(*@deferred_args)
  elsif @deferred_status != :failed
    @callbacks ||= []
    @callbacks.unshift block # << block
  end
  self
end