Class: Apia::Notifications
- Inherits:
-
Object
- Object
- Apia::Notifications
- Defined in:
- lib/apia/notifications.rb
Class Method Summary collapse
- .add_handler(handler = nil, &block) ⇒ Object
- .clear_handlers ⇒ Object
- .handlers ⇒ Object
- .notify(event, args = {}) ⇒ Object
Class Method Details
.add_handler(handler = nil, &block) ⇒ Object
18 19 20 21 |
# File 'lib/apia/notifications.rb', line 18 def add_handler(handler = nil, &block) handlers.push(block) if block handlers.push(handler) if handler end |
.clear_handlers ⇒ Object
23 24 25 |
# File 'lib/apia/notifications.rb', line 23 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 |