module Reactor
This module is where named worker classes will live - examples: Reactor::StaticSubscribers::ArbitraryModule::WilcardHandler Reactor::StaticSubscribers::ArbitraryModule::MyEventNameHandler
EventWorker is an abstract worker for handling events defined by on_event. You can create handlers by subclassing and redefining the configuration class methods, or by using Reactor::Workers::EventWorker.dup and overriding the methods on the new class.
MailerWorker has a bit more to do than EventWorker. It has to run the event, then if the output is a Mail::Message or the like it needs to deliver it like ActionMailer would
Constants
- BASE_VALIDATOR
- SUBSCRIBERS
- VERSION
Public Instance Methods
# File lib/reactor.rb, line 24 def add_subscriber(event_name, worker_class) subscribers[event_name] ||= [] subscribers[event_name] << worker_class end
# File lib/reactor.rb, line 33 def subscriber_namespace Reactor::StaticSubscribers end
# File lib/reactor.rb, line 20 def subscribers SUBSCRIBERS end
# File lib/reactor.rb, line 29 def subscribers_for(event_name) Array(subscribers[event_name]) + Array(subscribers['*']) end
If you want, you can inject your own validator block in `config/initializers/reactor.rb`
Reactor.validator
-> (event) { Validator.new(event).validate! }
If not, the default behavior is to do nothing. (see Reactor::BASE_VALIDATOR
)
# File lib/reactor.rb, line 44 def validator(block = nil) @validator = block if block.present? @validator || BASE_VALIDATOR end