class RailsDomainModel::CommandHandler

Public Class Methods

new(command) click to toggle source
# File lib/rails_domain_model/command_handler.rb, line 2
def initialize(command)
  @command = command
end

Public Instance Methods

handle!() click to toggle source
# File lib/rails_domain_model/command_handler.rb, line 6
def handle!
  aggregate = aggregate_class.new._load(stream_name)
  aggregate.send(aggregate_method, @command)
  aggregate._store
end

Private Instance Methods

aggregate_class() click to toggle source
# File lib/rails_domain_model/command_handler.rb, line 18
def aggregate_class
  @command.class.aggregate_class
end
aggregate_id() click to toggle source
# File lib/rails_domain_model/command_handler.rb, line 22
def aggregate_id
  @command.send(@command.class.aggregate_id_attribute)
end
aggregate_method() click to toggle source
# File lib/rails_domain_model/command_handler.rb, line 26
def aggregate_method
  @command.class.aggregate_method
end
stream_name() click to toggle source
# File lib/rails_domain_model/command_handler.rb, line 14
def stream_name
  "#{aggregate_class}$#{aggregate_id}"
end