lib/submodules/ably-ruby/lib/ably/modules/state_emitter.rb in ably-rest-1.0.5 vs lib/submodules/ably-ruby/lib/ably/modules/state_emitter.rb in ably-rest-1.0.6
- old
+ new
@@ -79,17 +79,17 @@
safe_yield block
else
failure_block = options.fetch(:else, nil)
failure_wrapper = nil
- success_wrapper = Proc.new do
+ success_wrapper = lambda do |*args|
yield
off(&success_wrapper)
off(&failure_wrapper) if failure_wrapper
end
- failure_wrapper = proc do |*args|
+ failure_wrapper = lambda do |*args|
failure_block.call(*args)
off(&success_wrapper)
off(&failure_wrapper)
end if failure_block
@@ -117,11 +117,11 @@
#
# @api private
def once_state_changed(options = {}, &block)
raise ArgumentError, 'Block required' unless block_given?
- once_block = proc do |*args|
+ once_block = lambda do |*args|
off(*self.class::STATE.map, &once_block)
yield(*args)
end
safe_unsafe_method options[:unsafe], :once, *self.class::STATE.map, &once_block
@@ -140,21 +140,21 @@
# 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|
- fail_proc = Proc.new do |state_change|
+ fail_proc = lambda 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
def self.included(klass)
- klass.configure_event_emitter coerce_into: Proc.new { |event|
+ klass.configure_event_emitter coerce_into: lambda { |event|
# Special case allows EVENT instead of STATE to be emitted
# Relies on the assumption that EVENT is a superset of STATE
if klass.const_defined?(:EVENT)
klass::EVENT(event)
else