Module: Hyrax::FileSet::BelongsToWorks

Extended by:
ActiveSupport::Concern
Included in:
Hyrax::FileSetBehavior
Defined in:
app/models/concerns/hyrax/file_set/belongs_to_works.rb

Instance Method Summary collapse

Instance Method Details

#parentObject

Returns the first parent object This is a hack to handle things like FileSets inheriting access controls from their parent. (see Hyrax::ParentContainer in app/controllers/concerns/curation_concers/parent_container.rb)



13
14
15
# File 'app/models/concerns/hyrax/file_set/belongs_to_works.rb', line 13

def parent
  parents.first
end

#parentsObject



7
8
9
# File 'app/models/concerns/hyrax/file_set/belongs_to_works.rb', line 7

def parents
  in_works
end

Files with sibling relationships Returns all FileSets aggregated by any of the parent objects that aggregate the current object



24
25
26
27
28
29
30
31
32
# File 'app/models/concerns/hyrax/file_set/belongs_to_works.rb', line 24

def related_files
  parent_objects = parents
  return [] if parent_objects.empty?
  parent_objects.flat_map do |work|
    work.file_sets.reject do |file_set|
      file_set.id == id
    end
  end
end