Class: Crimson::NotificationBus
- Inherits:
-
Object
- Object
- Crimson::NotificationBus
- Defined in:
- lib/crimson/notification_bus.rb
Instance Attribute Summary collapse
-
#notification_handlers ⇒ Object
readonly
Returns the value of attribute notification_handlers.
Instance Method Summary collapse
-
#initialize ⇒ NotificationBus
constructor
A new instance of NotificationBus.
- #notify(message) ⇒ Object
- #register(object) ⇒ Object
- #unregister(object) ⇒ Object
Constructor Details
#initialize ⇒ NotificationBus
Returns a new instance of NotificationBus.
9 10 11 |
# File 'lib/crimson/notification_bus.rb', line 9 def initialize @notification_handlers = Hashie::Mash.new end |
Instance Attribute Details
#notification_handlers ⇒ Object (readonly)
Returns the value of attribute notification_handlers.
7 8 9 |
# File 'lib/crimson/notification_bus.rb', line 7 def notification_handlers @notification_handlers end |
Instance Method Details
#notify(message) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/crimson/notification_bus.rb', line 27 def notify() unless notification_handlers.key?(.id) raise ArgumentError, "[NotificationBus] Trying to notify unregistered '#{.id}'." end notification_handlers[.id].call() end |