Sha256: 2f56f708a581ddfd5f1b165ed3902a2095af668622373dc7110b0817e110b3e8

Contents?: true

Size: 615 Bytes

Versions: 3

Compression:

Stored size: 615 Bytes

Contents

module Ddr::Derivatives
  class UpdateDerivatives

    def self.call(*args)
      event = ActiveSupport::Notifications::Event.new(*args)
      if event.name == "delete.repo_file" &&
         !file_ids.include?(event.payload[:file_id])
        return false
      end
      if event.name =~ /\.repo_object\z/ &&
         (file_ids & event.payload[:datastreams_changed]).empty?
        return false
      end
      obj = ActiveFedora::Base.find(event.payload[:pid])
      obj.derivatives.update_derivatives(:later)
    end

    def self.file_ids
      Ddr::Datastreams.update_derivatives_on_changed
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ddr-models-2.7.1 lib/ddr/derivatives/update_derivatives.rb
ddr-models-2.7.0 lib/ddr/derivatives/update_derivatives.rb
ddr-models-2.7.0.rc1 lib/ddr/derivatives/update_derivatives.rb