lib/reactor/event.rb in reactor-0.3.1 vs lib/reactor/event.rb in reactor-0.3.2
- old
+ new
@@ -54,12 +54,17 @@
#TODO: support more matching?
Reactor::Subscriber.where(event: '*').each do |s|
Reactor::Subscriber.delay.fire s.id, data
end
- if (static_subscribers = Reactor::STATIC_SUBSCRIBERS[name.to_s] || []).any?
+ if (static_subscribers = Reactor::SUBSCRIBERS[name.to_s] || []).any?
static_subscribers.each do |callback|
- callback.call(Reactor::Event.new(data.merge(event: name.to_s)))
+ case callback
+ when Hash
+ callback.keys.first.send callback.values.first, Reactor::Event.new(data.merge(event: name.to_s))
+ else
+ callback.call Reactor::Event.new(data.merge(event: name.to_s))
+ end
end
end
end
private