Sha256: 3b8377df28348449b72caf9ffe675500a6466c887f52cd51512d061149fac67f

Contents?: true

Size: 1.11 KB

Versions: 36

Compression:

Stored size: 1.11 KB

Contents

module Hyrax
  module 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

36 entries across 36 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-2.9.5 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-2.9.4 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-2.9.3 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-2.9.2 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-2.9.1 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-2.9.0 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-2.8.0 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-2.7.2 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-2.7.1 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-2.7.0 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-2.6.0 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-3.0.0.pre.rc1 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-3.0.0.pre.beta3 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-2.5.1 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-2.5.0 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-3.0.0.pre.beta2 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-2.4.1 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-3.0.0.pre.beta1 app/models/concerns/hyrax/file_set/belongs_to_works.rb
hyrax-2.4.0 app/models/concerns/hyrax/file_set/belongs_to_works.rb