Class: HecksEvents
- Inherits:
-
Object
- Object
- HecksEvents
- Defined in:
- lib/events.rb
Overview
Send lifecycle events to listeners
Instance Method Summary collapse
-
#initialize(listeners: []) ⇒ HecksEvents
constructor
A new instance of HecksEvents.
- #send(module_name:, command:) ⇒ Object
Constructor Details
#initialize(listeners: []) ⇒ HecksEvents
Returns a new instance of HecksEvents.
5 6 7 |
# File 'lib/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.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 |