Class: Sequent::Core::CommandRecord

Inherits:
ApplicationRecord 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



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

def children
  event_records
end

#find_origin(record) ⇒ Object



56
57
58
59
# File 'lib/sequent/core/command_record.rb', line 56

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

#originObject



52
53
54
# File 'lib/sequent/core/command_record.rb', line 52

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

#parentObject



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

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