Sha256: 3c216bf5da4b01dbaee99dd376dae0573be374125fb168cee1c20990e4c540bd

Contents?: true

Size: 1.14 KB

Versions: 28

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true
module Hyrax
  class FileSet
    module BelongsToWorks
      extend ActiveSupport::Concern

      def parents
        in_works
      end

      # 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)
      def parent
        parents.first
      end

      # Returns the id of 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)
      delegate :id, to: :parent, prefix: true

      # Files with sibling relationships
      # Returns all FileSets aggregated by any of the parent objects that
      # aggregate the current object
      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
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
hyrax-5.0.4 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-5.0.3 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-5.0.2 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-5.0.1 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-5.0.0 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-5.0.0.rc3 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-5.0.0.rc2 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-5.0.0.rc1 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-3.6.0 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-4.0.0 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-4.0.0.rc3 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-4.0.0.rc2 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-4.0.0.rc1 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-3.5.0 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-4.0.0.beta2 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-3.4.2 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-4.0.0.beta1 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-3.4.1 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-3.4.0 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-3.3.0 app/models/concerns/hyrax/file_set/belongs_to_works.rb