class RailsDomainModel::Command

Attributes

aggregate_class[RW]
aggregate_id_attribute[RW]
aggregate_method[RW]

Public Class Methods

with_aggregate(klass, id_attribute, method) click to toggle source
# File lib/rails_domain_model/command.rb, line 13
def self.with_aggregate(klass, id_attribute, method)
  @aggregate_class        = klass
  @aggregate_id_attribute = id_attribute
  @aggregate_method       = method

  validates @aggregate_id_attribute, presence: true
end

Public Instance Methods

execute!() click to toggle source
# File lib/rails_domain_model/command.rb, line 21
def execute!
  validate!

  RailsDomainModel::CommandHandler.new(self).handle!
end

Private Instance Methods

validate!() click to toggle source
# File lib/rails_domain_model/command.rb, line 29
def validate!
  fail ValidationError.new(errors), errors.messages.inspect unless valid?
end