lib/reactor/models/concerns/subscribable.rb in reactor-0.3.2 vs lib/reactor/models/concerns/subscribable.rb in reactor-0.4.0

- old
+ new

@@ -1,16 +1,11 @@ module Reactor::Subscribable extend ActiveSupport::Concern module ClassMethods - def on_event(event, method = nil, &block) - callback = case method - when Symbol - {self => method} - else - method - end - callback = block if block + def on_event(event, method = nil, options = {}, &block) + callback = {method: (method || block), options: {delay: 0}.merge(options)} + callback.merge!(source: self) if method.is_a? Symbol (Reactor::SUBSCRIBERS[event.to_s] ||= []).push(callback) end end end \ No newline at end of file