Class: Hyrax::Actors::ActorStack

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(curation_concern, user_or_ability, more_actors) ⇒ ActorStack

Returns a new instance of ActorStack.



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

def initialize(curation_concern, user_or_ability, more_actors)
  @curation_concern = curation_concern
  self.user = user_or_ability
  @more_actors = more_actors
  @first_actor_class = @more_actors.shift || RootActor
end

Instance Attribute Details

#curation_concernObject (readonly)

Returns the value of attribute curation_concern.



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

def curation_concern
  @curation_concern
end

#first_actor_classObject (readonly)

Returns the value of attribute first_actor_class.



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

def first_actor_class
  @first_actor_class
end

#more_actorsObject (readonly)

Returns the value of attribute more_actors.



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

def more_actors
  @more_actors
end

#userObject

Returns the value of attribute user.



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

def user
  @user
end

Instance Method Details

#abilityObject



40
41
42
# File 'app/actors/hyrax/actors/actor_stack.rb', line 40

def ability
  @ability ||= ::Ability.new(user)
end

#actorObject



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

def actor
  ## Change this to pass in the ability instead of user for next version.
  first_actor_class.new(curation_concern, user, inner_stack, ability: ability)
end

#create(new_attributes) ⇒ Object

Parameters:

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


22
23
24
# File 'app/actors/hyrax/actors/actor_stack.rb', line 22

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

#destroyObject



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

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



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

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

#update(new_attributes) ⇒ Object

Parameters:

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


27
28
29
# File 'app/actors/hyrax/actors/actor_stack.rb', line 27

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