lib/amq/client/callbacks.rb in amq-client-0.7.0.alpha25 vs lib/amq/client/callbacks.rb in amq-client-0.7.0.alpha26
- old
+ new
@@ -31,30 +31,39 @@
@callbacks[event].clear if @callbacks[event]
end # clear_callbacks(event)
def exec_callback(name, *args, &block)
- callbacks = Array(self.callbacks[name])
- callbacks.map { |c| c.call(*args, &block) } if callbacks.any?
+ list = Array(self.callbacks[name])
+ if list.any?
+ list.each { |c| c.call(*args, &block) }
+ end
end
def exec_callback_once(name, *args, &block)
- callbacks = Array(self.callbacks.delete(name))
- callbacks.map { |c| c.call(*args, &block) } if callbacks.any?
+ list = (self.callbacks.delete(name) || Array.new)
+ if list.any?
+ list.each { |c| c.call(*args, &block) }
+ end
end
def exec_callback_yielding_self(name, *args, &block)
- callbacks = Array(self.callbacks[name])
- callbacks.map { |c| c.call(self, *args, &block) } if callbacks.any?
+ list = Array(self.callbacks[name])
+ if list.any?
+ list.each { |c| c.call(self, *args, &block) }
+ end
end
def exec_callback_once_yielding_self(name, *args, &block)
- callbacks = Array(self.callbacks.delete(name))
- callbacks.map { |c| c.call(self, *args, &block) } if callbacks.any?
+ list = (self.callbacks.delete(name) || Array.new)
+
+ if list.any?
+ list.each { |c| c.call(self, *args, &block) }
+ end
end
def has_callback?(name)
self.callbacks[name] && !self.callbacks[name].empty?
end # has_callback?
end # Callbacks
end # Client
-end # AMQ
\ No newline at end of file
+end # AMQ