Class: Hyrax::Actors::OrderedMembersActor

Inherits:
FileSetActor show all
Includes:
Lockable
Defined in:
app/actors/hyrax/actors/ordered_members_actor.rb

Instance Attribute Summary collapse

Attributes inherited from FileSetActor

#attributes, #file_set

Instance Method Summary collapse

Methods included from Lockable

#acquire_lock_for, #lock_manager

Methods inherited from FileSetActor

#attach_to_work, #create_content, #create_metadata, #destroy, #revert_content, #update_content, #update_metadata

Constructor Details

#initialize(ordered_members, user) ⇒ OrderedMembersActor

Returns a new instance of OrderedMembersActor.



9
10
11
12
# File 'app/actors/hyrax/actors/ordered_members_actor.rb', line 9

def initialize(ordered_members, user)
  @ordered_members = ordered_members
  @user = user
end

Instance Attribute Details

#ordered_membersObject (readonly)

Returns the value of attribute ordered_members.



7
8
9
# File 'app/actors/hyrax/actors/ordered_members_actor.rb', line 7

def ordered_members
  @ordered_members
end

#userObject (readonly)

Returns the value of attribute user.



7
8
9
# File 'app/actors/hyrax/actors/ordered_members_actor.rb', line 7

def user
  @user
end

Instance Method Details

#attach_ordered_members_to_work(work) ⇒ Object

Adds FileSets to the work using ore:Aggregations. Locks to ensure that only one process is operating on the list at a time.

Parameters:



17
18
19
20
21
22
23
24
25
# File 'app/actors/hyrax/actors/ordered_members_actor.rb', line 17

def attach_ordered_members_to_work(work)
  acquire_lock_for(work.id) do
    work.ordered_members = ordered_members
    work.save
    ordered_members.each do |file_set|
      Hyrax.config.callback.run(:after_create_fileset, file_set, user, warn: false)
    end
  end
end