Class: RailsSimpleEventSourcing::CommandHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_simple_event_sourcing/command_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ CommandHandler

Returns a new instance of CommandHandler.



5
6
7
# File 'lib/rails_simple_event_sourcing/command_handler.rb', line 5

def initialize(command)
  @command = command
end

Instance Method Details

#callObject



9
10
11
12
13
# File 'lib/rails_simple_event_sourcing/command_handler.rb', line 9

def call
  return Result.new(success?: false, errors: @command.errors) unless @command.valid?

  initialize_command_handler.call
end