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)


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

def parent
  parents.first
end

#parentsObject


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

def parents
  in_works
end

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


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

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