Class: Rma::ItemsAddedNoteHandler
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- Rma::ItemsAddedNoteHandler
- Includes:
- RailsEventStore::AsyncHandler
- Defined in:
- app/subscribers/rma/items_added_note_handler.rb
Overview
Notes the RMA's current top-level items with their return reason codes
(#record_items_added_activity) when Events::RmaItemsAdded is
published, separating the lines this event added from the ones already on
the RMA. No-op when the RMA vanished between publish and perform; the
model method itself dedupes unchanged item lists.
Instance Method Summary collapse
Instance Method Details
#perform(event) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/subscribers/rma/items_added_note_handler.rb', line 14 def perform(event) rma = Rma.find_by(id: event.data[:rma_id]) return unless rma # Attribute the note's audit-trail rows to the employee who last # touched the RMA (the item entry), falling back to the handler as # system actor. PaperTrail.request(whodunnit: rma.updater_id || rma.creator_id || 'Rma::ItemsAddedNoteHandler') do rma.record_items_added_activity(rma.rma_items.includes(:returned_item), added_ids: event.data[:added_rma_item_ids]) end end |