Module: TCB::HandlesCommands::ClassMethods

Defined in:
lib/tcb/handles_commands.rb

Instance Method Summary collapse

Instance Method Details

#command_handler_registrationsObject



26
27
28
# File 'lib/tcb/handles_commands.rb', line 26

def command_handler_registrations
  @command_handler_registrations
end

#handle(command_class, handler) ⇒ Object



13
14
15
16
17
18
# File 'lib/tcb/handles_commands.rb', line 13

def handle(command_class, handler)
  @command_handler_registrations << CommandHandlerRegistration.new(
    command_class: command_class,
    handler: handler
  )
end

#with(*handlers) ⇒ Object

Raises:

  • (ArgumentError)


20
21
22
23
24
# File 'lib/tcb/handles_commands.rb', line 20

def with(*handlers)
  raise ArgumentError, "command accepts exactly one handler" unless handlers.compact.size == 1

  handlers.first
end