Class: Sequent::Core::CommandRecord

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/sequent/core/command_record.rb

Overview

For storing Sequent::Core::Command in the database using active_record

Instance Method Summary collapse

Instance Method Details

#commandObject



11
12
13
14
# File 'lib/sequent/core/command_record.rb', line 11

def command
  args = JSON.parse(command_json)
  Class.const_get(command_type.to_sym).deserialize_from_json(args)
end

#command=(command) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/sequent/core/command_record.rb', line 16

def command=(command)
  self.created_at = command.created_at
  self.aggregate_id = command.aggregate_id if command.respond_to? :aggregate_id
  self.organization_id = command.organization_id if command.respond_to? :organization_id
  self.user_id = command.user_id if command.respond_to? :user_id
  self.command_type = command.class.name
  self.command_json = command.to_json.to_s
end