Sha256: ce6d5a8a8c451d7a60956a74e6863ca5e8def7f43769487dbf8181a9d6b2d7fc

Contents?: true

Size: 815 Bytes

Versions: 10

Compression:

Stored size: 815 Bytes

Contents

module CurationConcerns
  module Actors
    class ApplyOrderActor < AbstractActor
      def update(attributes)
        ordered_member_ids = attributes.delete(:ordered_member_ids)
        apply_order(ordered_member_ids) && next_actor.update(attributes)
      end

      private

        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

10 entries across 10 versions & 1 rubygems

Version Path
curation_concerns-1.0.0 app/actors/curation_concerns/actors/apply_order_actor.rb
curation_concerns-1.0.0.beta10 app/actors/curation_concerns/actors/apply_order_actor.rb
curation_concerns-1.0.0.beta9 app/actors/curation_concerns/actors/apply_order_actor.rb
curation_concerns-1.0.0.beta8 app/actors/curation_concerns/actors/apply_order_actor.rb
curation_concerns-1.0.0.beta7 app/actors/curation_concerns/actors/apply_order_actor.rb
curation_concerns-1.0.0.beta6 app/actors/curation_concerns/actors/apply_order_actor.rb
curation_concerns-1.0.0.beta5 app/actors/curation_concerns/actors/apply_order_actor.rb
curation_concerns-1.0.0.beta4 app/actors/curation_concerns/actors/apply_order_actor.rb
curation_concerns-1.0.0.beta3 app/actors/curation_concerns/actors/apply_order_actor.rb
curation_concerns-1.0.0.beta2 app/actors/curation_concerns/actors/apply_order_actor.rb