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
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 is 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
-
#callback(&block) ⇒ Object
Specify a block to be executed if and when the Deferrable object receives a status of :succeeded.
-
#errback(&block) ⇒ Object
Specify a block to be executed if and when the Deferrable object receives a status of :failed.
-
#fail(*args) ⇒ Object
Mark the Deferrable as failed and trigger all callbacks See www.rubydoc.info/gems/eventmachine/1.0.7/EventMachine/Deferrable#fail-instance_method.
-
#succeed(*args) ⇒ Object
Mark the Deferrable as succeeded and trigger all callbacks See www.rubydoc.info/gems/eventmachine/1.0.7/EventMachine/Deferrable#succeed-instance_method.
Instance Method Details
#callback(&block) ⇒ Object
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
21 22 23 24 25 |
# File 'lib/ably/modules/safe_deferrable.rb', line 21 def callback(&block) super do |*args| safe_deferrable_block(*args, &block) end end |
#errback(&block) ⇒ Object
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
30 31 32 33 34 |
# File 'lib/ably/modules/safe_deferrable.rb', line 30 def errback(&block) super do |*args| safe_deferrable_block(*args, &block) end end |
#fail(*args) ⇒ Object
Mark the Deferrable as failed and trigger all callbacks See www.rubydoc.info/gems/eventmachine/1.0.7/EventMachine/Deferrable#fail-instance_method
44 45 46 |
# File 'lib/ably/modules/safe_deferrable.rb', line 44 def fail(*args) super(*args) end |
#succeed(*args) ⇒ Object
Mark the Deferrable as succeeded and trigger all callbacks See www.rubydoc.info/gems/eventmachine/1.0.7/EventMachine/Deferrable#succeed-instance_method
38 39 40 |
# File 'lib/ably/modules/safe_deferrable.rb', line 38 def succeed(*args) super(*args) end |