Sha256: b1ced5924ee2483064dd4815e4ce6b566d0ba4c8636659820b4c52799eb21d7d
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
module CurationConcerns module Actors class AddAsMemberOfCollectionsActor < AbstractActor def create(attributes) collection_ids = attributes.delete(:member_of_collection_ids) add_to_collections(collection_ids) && next_actor.create(attributes) end def update(attributes) collection_ids = attributes.delete(:member_of_collection_ids) add_to_collections(collection_ids) && next_actor.update(attributes) end private # Maps from collection ids to collection objects def add_to_collections(collection_ids) return true unless collection_ids # grab/save collections this user has no edit access to other_collections = curation_concern.member_of_collections.select { |coll| !coll.edit_users.include?(user.user_key) } curation_concern.member_of_collections = collection_ids.map { |id| ::Collection.find(id) } curation_concern.member_of_collections.concat other_collections end end end end
Version data entries
2 entries across 2 versions & 1 rubygems