Class: DBWrapper::ListenersController

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

Instance Method Summary collapse

Constructor Details

#initialize(listeners) ⇒ ListenersController

Returns a new instance of ListenersController.



4
5
6
# File 'lib/db_wrapper/listeners_controller.rb', line 4

def initialize(listeners)
  @listeners = listeners
end

Instance Method Details

#call_listeners(protocol, raw_command) ⇒ Object



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

def call_listeners(protocol, raw_command)
  return if @listeners.nil?
  parsed_command = protocol.parse_command raw_command
  return if parsed_command.empty?
  @listeners.select { |listener| listener.listening?(parsed_command) }.each do |listener|
    listener.command = parsed_command
    listener.perform
  end
end