Module: Hyrax::Collections::NestedCollectionPersistenceService

Defined in:
app/services/hyrax/collections/nested_collection_persistence_service.rb

Class Method Summary collapse

Class Method Details

.persist_nested_collection_for(parent:, child:, user: nil) ⇒ Object

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 wiki.lyrasis.org/display/samvera/Samvera+Tech+Call+2017-08-23 for tech discussion.

Responsible for persisting the relationship between the parent and the child.

Parameters:

See Also:


16
17
18
19
# File 'app/services/hyrax/collections/nested_collection_persistence_service.rb', line 16

def self.persist_nested_collection_for(parent:, child:, user: nil)
  child_resource = child.respond_to?(:valkyrie_resource) ? child.valkyrie_resource : child
  Hyrax::Collections::CollectionMemberService.add_member(collection_id: parent.id, new_member: child_resource, user: user)
end

.remove_nested_relationship_for(parent:, child:, user: nil) ⇒ Object

Parameters:


24
25
26
27
28
# File 'app/services/hyrax/collections/nested_collection_persistence_service.rb', line 24

def self.remove_nested_relationship_for(parent:, child:, user: nil)
  child_resource = child.respond_to?(:valkyrie_resource) ? child.valkyrie_resource : child
  Hyrax::Collections::CollectionMemberService.remove_member(collection_id: parent.id, member: child_resource, user: user)
  true
end