lib/faye/websocket/api/event_target.rb in faye-websocket-0.10.3 vs lib/faye/websocket/api/event_target.rb in faye-websocket-0.10.4

- old
+ new

@@ -35,23 +35,26 @@ listener = instance_variable_get("@on#{ event.type }") count = listener_count(event.type) unless listener or count > 0 - @buffers ||= Hash.new { |k,v| k[v] = [] } - @buffers[event.type].push(event) + event_buffers[event.type].push(event) end listener.call(event) if listener emit(event.type, event) end private def flush(event_type, listener) - if buffer = @buffers && @buffers.delete(event_type.to_s) + if buffer = event_buffers.delete(event_type.to_s) buffer.each { |event| listener.call(event) } end + end + + def event_buffers + @event_buffers ||= Hash.new { |k,v| k[v] = [] } end end end