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



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

def children
  event_records
end

#find_origin(record) ⇒ Object



63
64
65
66
67
# File 'lib/sequent/core/command_record.rb', line 63

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

  record
end

#originObject



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

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

#parentObject



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

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