Class: IiifPrint::Listener
- Inherits:
-
Object
- Object
- IiifPrint::Listener
- Defined in:
- app/listeners/iiif_print/listener.rb
Instance Method Summary collapse
-
#on_file_characterized(event, service: IiifPrint::SplitPdfs::ChildWorkCreationFromPdfService) ⇒ Object
Responsible for conditionally enqueuing the creation of child works from a PDF.
Instance Method Details
#on_file_characterized(event, service: IiifPrint::SplitPdfs::ChildWorkCreationFromPdfService) ⇒ Object
Responsible for conditionally enqueuing the creation of child works from a PDF.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/listeners/iiif_print/listener.rb', line 14 def on_file_characterized(event, service: IiifPrint::SplitPdfs::ChildWorkCreationFromPdfService) file_set = event[:file_set] return false unless file_set return false unless file_set.file_set? return false unless file_set.original_file&.respond_to?(:pdf?) return false unless file_set.original_file&.pdf? work = IiifPrint.parent_for(file_set) # A short-circuit to avoid fetching the underlying file. return false unless work user = work.depositor # TODO: Verify that this is the correct thing to be sending off for conditional enquing. That # will require a more involved integration test. file = file_set.original_file service.conditionally_enqueue(file_set: file_set, work: work, file: file, user: user) end |