Class: IiifPrint::Jobs::CreateRelationshipsJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
lib/iiif_print/jobs/create_relationships_job.rb

Overview

Break a pdf into individual pages

Instance Method Summary collapse

Instance Method Details

#perform(user:, parent_id:, parent_model:, child_model:) ⇒ Object

Link newly created child works to the parent

Parameters:

  • user: (User)

    user

  • parent_id: (<String>)

    parent work id

  • parent_model: (<String>)

    parent model

  • child_model: (<String>)

    child model



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/iiif_print/jobs/create_relationships_job.rb', line 10

def perform(user:, parent_id:, parent_model:, child_model:)
  if completed_child_data_for(parent_id, child_model)
    # add the members
    parent_work = parent_model.constantize.find(parent_id)
    create_relationships(user: user, parent: parent_work, ordered_children: @child_works)
    @pending_children.each(&:destroy)
  else
    # reschedule the job and end this one normally
    #
    # TODO: Depending on how things shake out, we could be infinitely rescheduling this job.
    # Consider a time to live parameter.
    reschedule(user: user, parent_id: parent_id, parent_model: parent_model, child_model: child_model)
  end
end