Sha256: c9d7824bddb889f591e1e13cee2d75d356ce86bccdf48ff4522a7531a4e6283d

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

module CurationConcerns
  module Actors
    class ActorStack
      attr_reader :curation_concern, :user, :first_actor_class, :more_actors
      def initialize(curation_concern, user, more_actors)
        @curation_concern = curation_concern
        @user = user
        @more_actors = more_actors
        @first_actor_class = @more_actors.shift || RootActor
      end

      def inner_stack
        Actors::ActorStack.new(curation_concern, user, more_actors)
      end

      def actor
        first_actor_class.new(curation_concern, user, inner_stack)
      end

      def create(attributes)
        actor.create(attributes.with_indifferent_access)
      end

      def update(attributes)
        actor.update(attributes.with_indifferent_access)
      end

      def destroy
        curation_concern.in_collection_ids.each do |id|
          destination_collection = ::Collection.find(id)
          destination_collection.members.delete(curation_concern)
          destination_collection.update_index
        end
        curation_concern.destroy
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
curation_concerns-1.3.3 app/actors/curation_concerns/actors/actor_stack.rb
curation_concerns-1.3.2 app/actors/curation_concerns/actors/actor_stack.rb
curation_concerns-1.3.1 app/actors/curation_concerns/actors/actor_stack.rb
curation_concerns-1.3.0 app/actors/curation_concerns/actors/actor_stack.rb
curation_concerns-1.2.0 app/actors/curation_concerns/actors/actor_stack.rb
curation_concerns-1.1.2 app/actors/curation_concerns/actors/actor_stack.rb
curation_concerns-1.1.1 app/actors/curation_concerns/actors/actor_stack.rb
curation_concerns-1.1.0 app/actors/curation_concerns/actors/actor_stack.rb
curation_concerns-1.0.0 app/actors/curation_concerns/actors/actor_stack.rb