Class: Apia::Notifications

Inherits:
Object
  • Object
show all
Defined in:
lib/apia/notifications.rb

Class Method Summary collapse

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_handlersObject



23
24
25
# File 'lib/apia/notifications.rb', line 23

def clear_handlers
  @handlers = nil
end

.handlersObject



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