Module: Hyrax::Collections::NestedCollectionPersistenceService
- Defined in:
- app/services/hyrax/collections/nested_collection_persistence_service.rb
Class Method Summary collapse
-
.persist_nested_collection_for(parent:, child:) ⇒ Object
Responsible for persisting the relationship between the parent and the child.
- .remove_nested_relationship_for(parent:, child:) ⇒ Object
Class Method Details
.persist_nested_collection_for(parent:, child:) ⇒ Object
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.duraspace.org/display/samvera/Samvera+Tech+Call+2017-08-23 for tech discussion.
Adding the member_of_collections method doesn’t trigger reindexing of the child so we have to do it manually. However it save and reindexes the parent unnecessarily!!
Responsible for persisting the relationship between the parent and the child.
16 17 18 19 20 |
# File 'app/services/hyrax/collections/nested_collection_persistence_service.rb', line 16 def self.persist_nested_collection_for(parent:, child:) parent.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX child.member_of_collections.push(parent) child.update_nested_collection_relationship_indices end |
.remove_nested_relationship_for(parent:, child:) ⇒ Object
Removing the member_of_collections method doesn’t trigger reindexing of the child so we have to do it manually. However it doesn’t save and reindex the parent, as it does when a parent is added!!
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:) child.member_of_collections.delete(parent) child.update_nested_collection_relationship_indices true end |