Class: VisibilityCopyJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
app/jobs/visibility_copy_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(work) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/jobs/visibility_copy_job.rb', line 2

def perform(work)
  work.file_sets.each do |file|
    file.visibility = work.visibility # visibility must come first, because it can clear an embargo/lease
    if work.lease
      file.build_lease unless file.lease
      file.lease.attributes = work.lease.attributes.except('id')
      file.lease.save
    end
    if work.embargo
      file.build_embargo unless file.embargo
      file.embargo.attributes = work.embargo.attributes.except('id')
      file.embargo.save
    end
    file.save!
  end
end