Sha256: 7daffe81092359ec6350b8fb2db65e97735a6dcf07e8fe76b6d0459e50a98116

Contents?: true

Size: 964 Bytes

Versions: 2

Compression:

Stored size: 964 Bytes

Contents

# Copied from Curate
module CurationConcerns
  module WithFileSets
    extend ActiveSupport::Concern

    included do
      # The file_sets association and its accessor methods comes from Hydra::Works::AggregatesFileSets
      before_destroy :cleanup_file_sets
    end

    # Stopgap unil ActiveFedora ContainerAssociation includes an *_ids accessor.
    # At the moment, this is no more efficient than calling file_sets, but hopefully that will change in the future.
    def file_set_ids
      file_sets.map(&:id)
    end

    def cleanup_file_sets
      # Destroy the list source first.  This prevents each file_set from attemping to
      # remove itself individually from the work. If hundreds of files are attached,
      # this would take too long.
      list_source.destroy
      file_sets.each(&:destroy)
    end

    def copy_visibility_to_files
      file_sets.each do |fs|
        fs.visibility = visibility
        fs.save!
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
curation_concerns-models-0.6.0 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-models-0.5.0 app/models/concerns/curation_concerns/with_file_sets.rb