Class: CurationConcerns::Actors::ActorStack

Inherits:
Object
  • Object
show all
Defined in:
app/actors/curation_concerns/actors/actor_stack.rb

Overview

Since:

  • 0.14.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(curation_concern, user, more_actors) ⇒ ActorStack

Returns a new instance of ActorStack.

Since:

  • 0.14.0



5
6
7
8
9
10
# File 'app/actors/curation_concerns/actors/actor_stack.rb', line 5

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

Instance Attribute Details

#curation_concernObject (readonly)

Since:

  • 0.14.0



4
5
6
# File 'app/actors/curation_concerns/actors/actor_stack.rb', line 4

def curation_concern
  @curation_concern
end

#first_actor_classObject (readonly)

Since:

  • 0.14.0



4
5
6
# File 'app/actors/curation_concerns/actors/actor_stack.rb', line 4

def first_actor_class
  @first_actor_class
end

#more_actorsObject (readonly)

Since:

  • 0.14.0



4
5
6
# File 'app/actors/curation_concerns/actors/actor_stack.rb', line 4

def more_actors
  @more_actors
end

#userObject (readonly)

Since:

  • 0.14.0



4
5
6
# File 'app/actors/curation_concerns/actors/actor_stack.rb', line 4

def user
  @user
end

Instance Method Details

#actorObject

Since:

  • 0.14.0



16
17
18
# File 'app/actors/curation_concerns/actors/actor_stack.rb', line 16

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

#create(new_attributes) ⇒ Object

Parameters:

  • new_attributes (ActionController::Parameters, Hash, NilClass)

Since:

  • 0.14.0



21
22
23
# File 'app/actors/curation_concerns/actors/actor_stack.rb', line 21

def create(new_attributes)
  actor.create(cast_to_indifferent_hash(new_attributes))
end

#destroyObject

Since:

  • 0.14.0



30
31
32
33
34
35
36
37
# File 'app/actors/curation_concerns/actors/actor_stack.rb', line 30

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

#inner_stackObject

Since:

  • 0.14.0



12
13
14
# File 'app/actors/curation_concerns/actors/actor_stack.rb', line 12

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

#update(new_attributes) ⇒ Object

Parameters:

  • new_attributes (ActionController::Parameters, Hash, NilClass)

Since:

  • 0.14.0



26
27
28
# File 'app/actors/curation_concerns/actors/actor_stack.rb', line 26

def update(new_attributes)
  actor.update(cast_to_indifferent_hash(new_attributes))
end