lib/submodules/ably-ruby/lib/ably/modules/event_emitter.rb in ably-rest-0.8.6 vs lib/submodules/ably-ruby/lib/ably/modules/event_emitter.rb in ably-rest-0.8.9
- old
+ new
@@ -37,11 +37,11 @@
@event_emitter_coerce_proc = options[:coerce_into]
end
# Ensure @event_emitter_coerce_proc option is passed down to any classes that inherit the class with callbacks
def inherited(subclass)
- subclass.instance_variable_set('@event_emitter_coerce_proc', @event_emitter_coerce_proc)
+ subclass.instance_variable_set('@event_emitter_coerce_proc', @event_emitter_coerce_proc) if defined?(@event_emitter_coerce_proc)
super
end
end
# On receiving an event matching the event_name, call the provided block
@@ -88,11 +88,11 @@
def emit(event_name, *args)
callbacks[callbacks_event_coerced(event_name)].
clone.
select do |proc_hash|
if proc_hash[:unsafe]
- proc_hash[:emit_proc].call *args
+ proc_hash[:emit_proc].call(*args)
else
safe_yield proc_hash[:emit_proc], *args
end
end.each do |callback|
callbacks[callbacks_event_coerced(event_name)].delete callback
@@ -131,10 +131,10 @@
# Create a Hash with a proc that calls the provided block and returns true if option :delete_once_run is set to true.
# #emit automatically deletes any blocks that return true thus allowing a block to be run once
def proc_for_block(block, options = {})
{
emit_proc: Proc.new do |*args|
- block.call *args
+ block.call(*args)
true if options[:delete_once_run]
end,
block: block,
unsafe: options[:unsafe]
}