Module: Hyrax::WithFileSets

Extended by:
ActiveSupport::Concern
Included in:
WorkBehavior
Defined in:
app/models/concerns/hyrax/with_file_sets.rb

Instance Method Summary collapse

Instance Method Details

#cleanup_file_setsObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/concerns/hyrax/with_file_sets.rb', line 16

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.

  # Get list of member file_sets from Solr
  fs = file_sets
  list_source.destroy
  # Remove Work from Solr after it was removed from Fedora
  ActiveFedora::SolrService.delete(id)
  fs.each(&:destroy)
end

#copy_visibility_to_filesObject



29
30
31
32
33
34
# File 'app/models/concerns/hyrax/with_file_sets.rb', line 29

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

#file_set_idsObject

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.



12
13
14
# File 'app/models/concerns/hyrax/with_file_sets.rb', line 12

def file_set_ids
  file_sets.map(&:id)
end