Class: Renalware::Letters::Printing::CompleteBatch

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/letters/printing/complete_batch.rb

Overview

Marks as completed a Batch and all Letters within it.

Instance Method Summary collapse

Instance Method Details

#callObject

TOD: Avoid loading all letters into memory



13
14
15
16
17
18
19
# File 'app/models/renalware/letters/printing/complete_batch.rb', line 13

def call
  Batch.transaction do
    batch.letters.each { |letter| CompleteLetter.build(letter).call(by: user) }
    batch.update_by(user, status: :success)
    batch.reload
  end
end