Class: Hecks::Adapters::Events

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

Instance Method Summary collapse

Constructor Details

#initialize(listeners: []) ⇒ Events



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

def initialize(listeners: [])
  @listeners = listeners
end

Instance Method Details

#send(module_name:, command:) ⇒ Object



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

def send(module_name:, command:)
  @command = command
  @module_name = module_name
  listeners.each do |listener|
    next unless listener.respond_to?(event_name)
    listener.public_send(event_name, command)
  end
end