Sha256: 3b7eae9e1dd6df646ee2cea1d05fe5ab70a665dbd0f777eeba535a6b8dfcf26b

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

module Hyrax
  module Transactions
    module Steps
      ##
      # For a FileSet that is a PDF, we need to delete any works and file_sets that are the result of
      # splitting that PDF into constituent images of each page of the PDF.  This is responsible for
      # that work.
      class ConditionallyDestroyChildrenFromSplit
        include Dry::Monads[:result]

        ##
        # @param resource [Hyrax::FileSet]
        def call(resource, user: nil)
          return Failure(:resource_not_persisted) unless resource.persisted?

          parent = IiifPrint.persistence_adapter.parent_for(resource)
          return Success(true) unless parent

          # We do not care about the results of this call; as it is conditionally looking for things
          # to destroy.
          IiifPrint::SplitPdfs::DestroyPdfChildWorksService.conditionally_destroy_spawned_children_of(
            file_set: resource,
            work: parent,
            user: user
          )

          Success(resource)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
iiif_print-3.0.4 app/transactions/hyrax/transactions/steps/conditionally_destroy_children_from_split.rb
iiif_print-3.0.3 app/transactions/hyrax/transactions/steps/conditionally_destroy_children_from_split.rb
iiif_print-3.0.2 app/transactions/hyrax/transactions/steps/conditionally_destroy_children_from_split.rb
iiif_print-3.0.1 app/transactions/hyrax/transactions/steps/conditionally_destroy_children_from_split.rb
iiif_print-3.0.0 app/transactions/hyrax/transactions/steps/conditionally_destroy_children_from_split.rb
iiif_print-2.0.1 app/transactions/hyrax/transactions/steps/conditionally_destroy_children_from_split.rb
iiif_print-2.0.0 app/transactions/hyrax/transactions/steps/conditionally_destroy_children_from_split.rb