Class: AttachFilesToWorkWithOrderedMembersJob

Inherits:
AttachFilesToWorkJob show all
Defined in:
app/jobs/attach_files_to_work_with_ordered_members_job.rb

Overview

Converts UploadedFiles into FileSets and attaches them to works.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ordered_membersObject (readonly)

Returns the value of attribute ordered_members.



3
4
5
# File 'app/jobs/attach_files_to_work_with_ordered_members_job.rb', line 3

def ordered_members
  @ordered_members
end

#uploaded_filesObject (readonly)

Returns the value of attribute uploaded_files.



3
4
5
# File 'app/jobs/attach_files_to_work_with_ordered_members_job.rb', line 3

def uploaded_files
  @uploaded_files
end

Instance Method Details

#perform(work, uploaded_files, **work_attributes) ⇒ Object

Parameters:

  • work (ActiveFedora::Base)
    • the work object

  • uploaded_files (Array<Hyrax::UploadedFile>)
    • an array of files to attach



7
8
9
10
11
12
13
14
15
16
# File 'app/jobs/attach_files_to_work_with_ordered_members_job.rb', line 7

def perform(work, uploaded_files, **work_attributes)
  @uploaded_files = uploaded_files
  validate_files!(uploaded_files)
  @ordered_members = work.ordered_members.to_a # Build array of ordered members
  depositor = proxy_or_depositor(work)
  user = User.find_by_user_key(depositor)
   = visibility_attributes(work_attributes)
  add_uploaded_files(user, , work)
  add_ordered_members(user, work)
end