Module: Lieutenant::CommandHandler

Defined in:
lib/lieutenant/command_handler.rb

Overview

Command handler helper. Allows clean syntax to register handlers:

module FooCommandHandler
  include Lieutenant::CommandHandler

  on(BarCommand) do |repository, command|
     # ...
  end
end

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



14
15
16
# File 'lib/lieutenant/command_handler.rb', line 14

def self.included(base)
  base.extend(self)
end

Instance Method Details

#on(command_class, &block) ⇒ Object

:reek:UtilityFunction



19
20
21
# File 'lib/lieutenant/command_handler.rb', line 19

def on(command_class, &block)
  Lieutenant.config.command_sender.register(command_class, block)
end