Module: Ably::Modules::SafeDeferrable

Includes:
EventMachine::Deferrable
Included in:
Ably::Models::Message, Ably::Models::PresenceMessage, Ably::Models::ProtocolMessage, Util::SafeDeferrable
Defined in:
lib/ably/modules/safe_deferrable.rb

Overview

Note:

this Module requires that the method #logger is available

SafeDeferrable module provides an EventMachine::Deferrable interface to the object it is included in and is safe to use for for public interfaces of this client library. Any exceptions raised in the success or failure callbacks are caught and logged to #logger

An exception in a callback provided by a developer should not break this client library and stop further execution of code.

See www.rubydoc.info/gems/eventmachine/1.0.7/EventMachine/Deferrable

Instance Method Summary collapse

Instance Method Details

#callback(&block) ⇒ void

This method returns an undefined value.

Specify a block to be executed if and when the Deferrable object receives a status of :succeeded. See www.rubydoc.info/gems/eventmachine/1.0.7/EventMachine/Deferrable#callback-instance_method



24
25
26
27
28
# File 'lib/ably/modules/safe_deferrable.rb', line 24

def callback(&block)
  super do |*args|
    safe_deferrable_block(*args, &block)
  end
end

#errback(&block) ⇒ void

This method returns an undefined value.

Specify a block to be executed if and when the Deferrable object receives a status of :failed. See www.rubydoc.info/gems/eventmachine/1.0.7/EventMachine/Deferrable#errback-instance_method



36
37
38
39
40
# File 'lib/ably/modules/safe_deferrable.rb', line 36

def errback(&block)
  super do |*args|
    safe_deferrable_block(*args, &block)
  end
end

#fail(*args) ⇒ void

This method returns an undefined value.

Mark the Deferrable as failed and trigger all error callbacks. See www.rubydoc.info/gems/eventmachine/1.0.7/EventMachine/Deferrable#fail-instance_method



56
57
58
# File 'lib/ably/modules/safe_deferrable.rb', line 56

def fail(*args)
  super(*args)
end

#succeed(*args) ⇒ void

This method returns an undefined value.

Mark the Deferrable as succeeded and trigger all success callbacks. See www.rubydoc.info/gems/eventmachine/1.0.7/EventMachine/Deferrable#succeed-instance_method



47
48
49
# File 'lib/ably/modules/safe_deferrable.rb', line 47

def succeed(*args)
  super(*args)
end