Module: CurationConcerns::FileSet::BelongsToWorks
- Extended by:
- ActiveSupport::Concern
- Included in:
- CurationConcerns::FileSetBehavior
- Defined in:
- app/models/concerns/curation_concerns/file_set/belongs_to_works.rb
Instance Method Summary collapse
-
#generic_work_ids ⇒ Object
OPTIMIZE: We can load this from Solr much faster than loading the objects.
- #generic_works ⇒ Object
-
#parent ⇒ Object
Returns the first parent object This is a hack to handle things like FileSets inheriting access controls from their parent.
-
#related_files ⇒ Object
Files with sibling relationships Returns all FileSets aggregated by any of the GenericWorks that aggregate the current object.
-
#remove_representative_relationship ⇒ Object
If any parent works are pointing at this object as their representative, remove that pointer.
Instance Method Details
#generic_work_ids ⇒ Object
OPTIMIZE: We can load this from Solr much faster than loading the objects
15 16 17 |
# File 'app/models/concerns/curation_concerns/file_set/belongs_to_works.rb', line 15 def generic_work_ids generic_works.map(&:id) end |
#generic_works ⇒ Object
10 11 12 |
# File 'app/models/concerns/curation_concerns/file_set/belongs_to_works.rb', line 10 def generic_works in_objects # in_objects is provided by Hydra::PCDM::ObjectBehavior end |
#parent ⇒ Object
Returns the first parent object This is a hack to handle things like FileSets inheriting access controls from their parent. (see CurationConcerns::ParentContainer in app/controllers/concerns/curation_concers/parent_container.rb)
21 22 23 |
# File 'app/models/concerns/curation_concerns/file_set/belongs_to_works.rb', line 21 def parent in_objects.first end |
#related_files ⇒ Object
Files with sibling relationships Returns all FileSets aggregated by any of the GenericWorks that aggregate the current object
31 32 33 34 35 |
# File 'app/models/concerns/curation_concerns/file_set/belongs_to_works.rb', line 31 def generic_works = self.generic_works return [] if generic_works.empty? generic_works.flat_map { |work| work.file_sets.select { |file_set| file_set.id != id } } end |
#remove_representative_relationship ⇒ Object
If any parent works are pointing at this object as their representative, remove that pointer.
38 39 40 41 42 43 44 |
# File 'app/models/concerns/curation_concerns/file_set/belongs_to_works.rb', line 38 def remove_representative_relationship generic_works = self.generic_works return if generic_works.empty? generic_works.each do |work| work.update(representative_id: nil) if work.representative_id == id end end |