Class: Rma::CreationNoteHandler

Inherits:
ApplicationJob show all
Includes:
RailsEventStore::AsyncHandler
Defined in:
app/subscribers/rma/creation_note_handler.rb

Overview

Writes the RMA's baseline creation note (#record_creation_activity)
when Events::RmaCreated is published — async off the request path so a
note-write failure surfaces as a retryable failed job, never as a broken
RMA create. No-op when the RMA vanished between publish and perform.

Instance Method Summary collapse

Instance Method Details

#perform(event) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'app/subscribers/rma/creation_note_handler.rb', line 13

def perform(event)
  rma = Rma.find_by(id: event.data[:rma_id])
  return unless rma

  # Attribute the note's audit-trail rows to the RMA's creator (the
  # employee who keyed it), falling back to the handler as system actor.
  PaperTrail.request(whodunnit: rma.creator_id || 'Rma::CreationNoteHandler') do
    rma.record_creation_activity
  end
end