Sha256: 2333c348196d19dfc4f14744e21100f482b659fe767206a27e5d738a1a628a44

Contents?: true

Size: 763 Bytes

Versions: 3

Compression:

Stored size: 763 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 :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 before_destroy_cleanup_file_sets
      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

3 entries across 3 versions & 1 rubygems

Version Path
curation_concerns-models-0.4.0 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-models-0.3.0 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-models-0.2.0 app/models/concerns/curation_concerns/with_file_sets.rb