class Sequent::Core::BaseCommandHandler
Base class for command handlers CommandHandlers are responsible for propagating a command to the correct Sequent::Core::AggregateRoot
or creating a new one. For example:
class InvoiceCommandHandler < Sequent::Core::BaseCommandHandler on CreateInvoiceCommand do |command| repository.add_aggregate Invoice.new(command.aggregate_id) end on PayInvoiceCommand do |command| do_with_aggregate(command, Invoice) {|invoice|invoice.pay(command.pay_date)} end end
Attributes
abstract_class[RW]
skip_autoregister[RW]
Protected Instance Methods
do_with_aggregate(command, clazz = nil, aggregate_id = nil) { |aggregate| ... }
click to toggle source
# File lib/sequent/core/base_command_handler.rb, line 36 def do_with_aggregate(command, clazz = nil, aggregate_id = nil) aggregate = repository.load_aggregate(aggregate_id.nil? ? command.aggregate_id : aggregate_id, clazz) yield aggregate if block_given? end
repository()
click to toggle source
# File lib/sequent/core/base_command_handler.rb, line 32 def repository Sequent.configuration.aggregate_repository end