Sha256: bf36441000d01da74f312c16ea1a58dd7a979390672610a2b2c2f82c29933b39

Contents?: true

Size: 949 Bytes

Versions: 2

Compression:

Stored size: 949 Bytes

Contents

module Hyrax
  module Collections
    module NestedCollectionPersistenceService
      # @api public
      #
      # Responsible for persisting the relationship between the parent and the child.
      # @see Hyrax::Collections::NestedCollectionQueryService
      #
      # @param parent [Collection]
      # @param child [Collection]
      # @note There is odd permission arrangement based on the NestedCollectionQueryService:
      #       You can nest the child within a parent if you can edit the parent and read the child.
      #       See https://wiki.duraspace.org/display/samvera/Samvera+Tech+Call+2017-08-23 for tech discussion.
      def self.persist_nested_collection_for(parent:, child:)
        child.member_of_collections << parent
        child.save
      end

      def self.remove_nested_relationship_for(parent:, child:)
        child.member_of_collections.delete(parent)
        child.save
        true
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hyrax-2.1.0.beta2 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-2.1.0.beta1 app/services/hyrax/collections/nested_collection_persistence_service.rb