Class: Sequent::Core::CommandRecord

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

Overview

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

Instance Method Summary collapse

Methods included from SerializesCommand

#command, #command=

Instance Method Details

#childrenObject



39
40
41
# File 'lib/sequent/core/command_record.rb', line 39

def children
  event_records
end

#find_origin(record) ⇒ Object



47
48
49
50
# File 'lib/sequent/core/command_record.rb', line 47

def find_origin(record)
  return find_origin(record.parent) if record.parent.present?
  record
end

#originObject



43
44
45
# File 'lib/sequent/core/command_record.rb', line 43

def origin
  parent.present? ? find_origin(parent) : self
end

#parentObject



35
36
37
# File 'lib/sequent/core/command_record.rb', line 35

def parent
  EventRecord.find_by(aggregate_id: event_aggregate_id, sequence_number: event_sequence_number)
end