Class: Lcms::Engine::MaterialGeneratePdfJob

Inherits:
ApplicationJob
  • Object
show all
Includes:
RetrySimple, ResqueJob
Defined in:
app/jobs/lcms/engine/material_generate_pdf_job.rb

Instance Method Summary collapse

Methods included from ResqueJob

included, #result_key, #store_initial_result, #store_result

Instance Method Details

#perform(material, document) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/jobs/lcms/engine/material_generate_pdf_job.rb', line 12

def perform(material, document)
  material_links = material.pdf? ? (material) : links_from_upload(material, document)

  new_links = {
    'materials' => {
      material.id.to_s => material_links
    }
  }

  document.with_lock do
    links = document.reload.links
    document.update links: links.deep_merge(new_links)
  end

  Lcms::Engine::DocumentGenerateJob.perform_later(document, check_queue: true)
end