Class: Faulty::Events::Notifier
- Inherits:
-
Object
- Object
- Faulty::Events::Notifier
- Defined in:
- lib/faulty/events/notifier.rb
Overview
The default event dispatcher for Faulty
Instance Method Summary collapse
-
#initialize(listeners = []) ⇒ Notifier
constructor
A new instance of Notifier.
-
#notify(event, payload) ⇒ Object
Notify all listeners of an event.
Constructor Details
#initialize(listeners = []) ⇒ Notifier
Returns a new instance of Notifier.
8 9 10 |
# File 'lib/faulty/events/notifier.rb', line 8 def initialize(listeners = []) @listeners = listeners.freeze end |
Instance Method Details
#notify(event, payload) ⇒ Object
Notify all listeners of an event
18 19 20 21 22 |
# File 'lib/faulty/events/notifier.rb', line 18 def notify(event, payload) raise ArgumentError, "Unknown event #{event}" unless EVENTS.include?(event) @listeners.each { |l| l.handle(event, payload) } end |