Class: Renalware::HD::SessionForms::BatchCompilePdfs
- Inherits:
-
Object
- Object
- Renalware::HD::SessionForms::BatchCompilePdfs
- Includes:
- PdfCompilation
- Defined in:
- app/models/renalware/hd/session_forms/batch_compile_pdfs.rb
Overview
Given a Batch object representing a request to ‘print’ (ie compile) a PDF of multiple HD Session Forms (aka protocols), where each batch.item points to the patient we want to print, we render each PDF in the current folder (we assume the caller has chdir’ed us into a tmp location), and then append them all together as <batchid>.pdf in a known location. The filepath is assigned to the batch and saved, so it can be served to a user via the user later.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(batch, user) ⇒ BatchCompilePdfs
constructor
A new instance of BatchCompilePdfs.
Methods included from PdfCompilation
#combine_multiple_pdfs_into_file, #combine_multiple_pdfs_using_filenames, #move_tempfile_to_output_file, #rails_tmp_folder, #shell_to_ghostscript_to_combine_files, #using_a_temporary_output_file
Constructor Details
#initialize(batch, user) ⇒ BatchCompilePdfs
Returns a new instance of BatchCompilePdfs.
22 23 24 25 26 |
# File 'app/models/renalware/hd/session_forms/batch_compile_pdfs.rb', line 22 def initialize(batch, user) @batch = batch @user = user @dir = Pathname(Dir.pwd) end |
Class Method Details
.call(batch, user) ⇒ Object
18 19 20 |
# File 'app/models/renalware/hd/session_forms/batch_compile_pdfs.rb', line 18 def self.call(batch, user) new(batch, user).call end |
Instance Method Details
#call ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/renalware/hd/session_forms/batch_compile_pdfs.rb', line 28 def call batch.update_by(user, status: :processing) process_batch_items batch.filepath = append_files batch.status = :awaiting_printing batch.save_by!(user) rescue StandardError => e batch.update(last_error: e., status: :failure) raise e end |