lib/ably/modules/state_emitter.rb in ably-0.8.3 vs lib/ably/modules/state_emitter.rb in ably-0.8.4
- old
+ new
@@ -139,10 +139,13 @@
# success block if provided and {Ably::Util::SafeDeferrable#callback} is called.
# If the state changes to any other state, the {Ably::Util::SafeDeferrable#errback} is called.
#
def deferrable_for_state_change_to(target_state)
Ably::Util::SafeDeferrable.new(logger).tap do |deferrable|
- once_or_if(target_state, else: proc { |*args| deferrable.fail self, *args }) do
+ fail_proc = Proc.new do |state_change|
+ deferrable.fail self, state_change.reason
+ end
+ once_or_if(target_state, else: fail_proc) do
yield self if block_given?
deferrable.succeed self
end
end
end