Class: Apia::Notifications
- Inherits:
-
Object
- Object
- Apia::Notifications
- Defined in:
- lib/apia/notifications.rb
Class Method Summary collapse
- .add_handler(&block) ⇒ Object
- .clear_handlers ⇒ Object
- .handlers ⇒ Object
- .notify(event, args = {}) ⇒ Object
Class Method Details
.add_handler(&block) ⇒ Object
18 19 20 |
# File 'lib/apia/notifications.rb', line 18 def add_handler(&block) handlers.push(block) end |
.clear_handlers ⇒ Object
22 23 24 |
# File 'lib/apia/notifications.rb', line 22 def clear_handlers @handlers = nil end |
.handlers ⇒ Object
8 9 10 |
# File 'lib/apia/notifications.rb', line 8 def handlers @handlers ||= [] end |
.notify(event, args = {}) ⇒ Object
12 13 14 15 16 |
# File 'lib/apia/notifications.rb', line 12 def notify(event, args = {}) handlers.each do |handler| handler.call(event, args) end end |