Sha256: 03c34b3a06de39fc1c384fb5ccd31b5bfd60b0f9e0146462a3f658f34f6439e3
Contents?: true
Size: 1.48 KB
Versions: 15
Compression:
Stored size: 1.48 KB
Contents
module CurationConcerns module Actors class ApplyOrderActor < AbstractActor def update(attributes) ordered_member_ids = attributes.delete(:ordered_member_ids) sync_members(ordered_member_ids) apply_order(ordered_member_ids) && next_actor.update(attributes) end private def sync_members(ordered_member_ids) return true if ordered_member_ids.nil? existing_members_ids = curation_concern.ordered_member_ids (existing_members_ids - ordered_member_ids).each do |old_id| work = ::ActiveFedora::Base.find(old_id) curation_concern.ordered_members.delete(work) curation_concern.members.delete(work) end (ordered_member_ids - existing_members_ids).each do |work_id| work = ::ActiveFedora::Base.find(work_id) curation_concern.ordered_members << work end curation_concern.save true end def apply_order(new_order) return true unless new_order curation_concern.ordered_member_proxies.each_with_index do |proxy, index| unless new_order[index] proxy.prev.next = curation_concern.ordered_member_proxies.last.next break end proxy.proxy_for = ActiveFedora::Base.id_to_uri(new_order[index]) proxy.target = nil end curation_concern.list_source.order_will_change! true end end end end
Version data entries
15 entries across 15 versions & 1 rubygems