class Hecks::Adapters::Events

Attributes

command[R]
listeners[R]
module_name[R]

Public Class Methods

new(listeners: []) click to toggle source
# File lib/events/events.rb, line 5
def initialize(listeners: [])
  @listeners = listeners
end

Public Instance Methods

send(module_name:, command:) click to toggle source
# 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

Private Instance Methods

event_name() click to toggle source
# File lib/events/events.rb, line 22
def event_name
  "#{module_name}_#{command.name}".to_sym
end