Class: Apia::Notifications

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

Class Method Summary collapse

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_handlersObject



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

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