Class: EventPeople::Listener

Inherits:
Object
  • Object
show all
Defined in:
lib/event_people/listener.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.on(event_name, &block) ⇒ Object



5
6
7
# File 'lib/event_people/listener.rb', line 5

def self.on(event_name, &block)
  new.on(event_name, &block)
end

Instance Method Details

#on(event_name, &block) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/event_people/listener.rb', line 9

def on(event_name, &block)
  raise(MissingAttributeError, 'Event name must be present') unless event_name&.size&.positive?

  event_name = consumed_event_name(event_name)

  EventPeople::Config.broker.consume(event_name, &block)
end