Class: EmbargoExpiryJob

Inherits:
Hyrax::ApplicationJob show all
Defined in:
app/jobs/embargo_expiry_job.rb

Instance Method Summary collapse

Instance Method Details

#performObject



3
4
5
6
7
8
# File 'app/jobs/embargo_expiry_job.rb', line 3

def perform
  records_with_expired_embargos.each do |resource|
    Hyrax::EmbargoManager.release_embargo_for(resource: resource) &&
      Hyrax::AccessControlList(resource).save
  end
end

#records_with_expired_embargosEnumerator<Valkyrie::Resource>

Returns ids for all the objects that have expired active embargoes.

Returns:

  • (Enumerator<Valkyrie::Resource>)

    ids for all the objects that have expired active embargoes



12
13
14
15
16
# File 'app/jobs/embargo_expiry_job.rb', line 12

def records_with_expired_embargos
  ids = Hyrax::EmbargoService.assets_with_expired_embargoes.map(&:id)

  Hyrax.query_service.find_many_by_ids(ids: ids)
end