lib/submodules/ably-ruby/lib/ably/modules/state_emitter.rb in ably-rest-0.8.3 vs lib/submodules/ably-ruby/lib/ably/modules/state_emitter.rb in ably-rest-0.8.5

- 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 state_change.reason + end + once_or_if(target_state, else: fail_proc) do yield self if block_given? deferrable.succeed self end end end