app/services/hyrax/collections/collection_member_service.rb
def add_member(collection_id:, new_member:, user:)
          message = Hyrax::MultipleMembershipChecker.new(item: new_member).check(collection_ids: [collection_id], include_current_members: true)
          raise Hyrax::SingleMembershipError, message if message.present?
          new_member.member_of_collection_ids << collection_id # only populate this direction
          new_member = Hyrax.persister.save(resource: new_member)
          publish_metadata_updated(new_member, user)
          new_member
        end
# Add a work or collection as a member of a collection
# @param collection_id [Valkyrie::ID] the id of the parent collection
# @param new_member [Hyrax::Resource] the new child collection or child work
# @return [Hyrax::Resource] updated member resource
Add a work or collection as a member of a collection
Add a work or collection as a member of a collection
def add_member(collection_id:, new_member:, user:)
          message = Hyrax::MultipleMembershipChecker.new(item: new_member).check(collection_ids: [collection_id], include_current_members: true)
          raise Hyrax::SingleMembershipError, message if message.present?
          new_member.member_of_collection_ids << collection_id 
          new_member = Hyrax.persister.save(resource: new_member)
          publish_metadata_updated(new_member, user)
          new_member
        end
def add_member ( collection_id : , new_member : , user : ) message = Hyrax :: MultipleMembershipChecker . new ( item : new_member ) . check ( collection_ids : [ collection_id ] , include_current_members : true ) raise Hyrax :: SingleMembershipError , message if message . present? new_member . member_of_collection_ids << collection_id new_member = Hyrax . persister . save ( resource : new_member ) publish_metadata_updated ( new_member , user ) new_member end
Add a work or collection as a member of a collection
Add a work or collection as a member of a collection
# only populate this direction
updated member resource
updated member resource
Hyrax::Resource
collection_id
the id of the parent collection
the id of the parent collection
new_member
the new child collection or child work
the new child collection or child work
user