Class: Bulkrax::DeleteFileSetJob

Inherits:
DeleteJob show all
Defined in:
app/jobs/bulkrax/delete_file_set_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(entry, importer_run) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/jobs/bulkrax/delete_file_set_job.rb', line 5

def perform(entry, importer_run)
  file_set = entry.factory.find
  if file_set
    parent = file_set.parent
    if parent&.respond_to?(:ordered_members)
      om = parent.ordered_members.to_a
      om.delete(file_set)
      parent.ordered_members = om
    elsif parent.respond_to?(:member_ids)
      parent.member_ids.delete(file_set.id)
      Hyrax.persister.save(resource: parent)
    end
    parent.save
  end

  super
end