Module: ROM::Notifications
Overview
Notification subsystem
This is an abstract event bus that implements a simple pub/sub protocol. The Notifications module is used in the setup process to decouple different modules from each other.
Defined Under Namespace
Modules: Listener, Publisher Classes: Event, EventBus
Constant Summary collapse
- LISTENERS_HASH =
Hash.new { |h, k| h[k] = [] }
Class Method Summary collapse
-
.event_bus(id) ⇒ Notifications::EventBus
Build an event bus.
- .events ⇒ Object private
- .listeners ⇒ Object private
Instance Method Summary collapse
-
#register_event(id, info = EMPTY_HASH) ⇒ Object
Register an event.
Methods included from Publisher
Class Method Details
.event_bus(id) ⇒ Notifications::EventBus
Build an event bus
168 169 170 |
# File 'lib/rom/support/notifications.rb', line 168 def self.event_bus(id) EventBus.new(id, events: events.dup, listeners: listeners.dup) end |
.events ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
153 154 155 |
# File 'lib/rom/support/notifications.rb', line 153 def self.events @__events__ ||= {} end |
.listeners ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
158 159 160 |
# File 'lib/rom/support/notifications.rb', line 158 def self.listeners @__listeners__ ||= LISTENERS_HASH.dup end |
Instance Method Details
#register_event(id, info = EMPTY_HASH) ⇒ Object
Register an event
148 149 150 |
# File 'lib/rom/support/notifications.rb', line 148 def register_event(id, info = EMPTY_HASH) Notifications.events[id] = Event.new(id, info) end |