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



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

def children
  event_records
end

#find_origin(record) ⇒ Object



59
60
61
62
# File 'lib/sequent/core/command_record.rb', line 59

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

#originObject



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

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

#parentObject



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

def parent
  EventRecord
    .where(aggregate_id: event_aggregate_id, sequence_number: event_sequence_number)
    .where('event_type != ?', Sequent::Core::SnapshotEvent.name)
    .first
end