Class: Lcms::Engine::DocumentGeneratePdfJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- Lcms::Engine::DocumentGeneratePdfJob
- Includes:
- RetrySimple, ResqueJob
- Defined in:
- app/jobs/lcms/engine/document_generate_pdf_job.rb
Constant Summary collapse
- PDF_EXPORTERS =
{ 'full' => ::DocumentExporter::Pdf::Document, 'sm' => ::DocumentExporter::Pdf::StudentMaterial, 'tm' => ::DocumentExporter::Pdf::TeacherMaterial }.freeze
Instance Method Summary collapse
Methods included from ResqueJob
included, #result_key, #store_initial_result, #store_result
Instance Method Details
#perform(doc, options) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/jobs/lcms/engine/document_generate_pdf_job.rb', line 17 def perform(doc, ) content_type = [:content_type] document = DocumentGenerator.document_presenter.new doc.reload, content_type: content_type filename = [:filename].presence || "#{::DocumentExporter::Pdf::Base.s3_folder}/#{document.pdf_filename}" pdf = PDF_EXPORTERS[content_type].new(document, ).export url = S3Service.upload filename, pdf return if [:excludes].present? key = ::DocumentExporter::Pdf::Base.pdf_key [:content_type] document.with_lock do document.update links: document.reload.links.merge(key => url) end end |