Class: Sipity::Runners::DoiRunners::AssignADoi

Inherits:
BaseRunner
  • Object
show all
Defined in:
app/runners/sipity/runners/doi_runners.rb

Overview

Responsible for assigning a DOI to the sip.

Instance Attribute Summary

Attributes inherited from BaseRunner

#authentication_layer, #authorization_layer

Instance Method Summary collapse

Methods inherited from BaseRunner

#authentication_layer_that_authenticates_anything, #authentication_layer_that_uses_context_authentication, #authorization_layer_that_authorizes_everything, #authorization_layer_with_enforcement, #enforce_authentication!, #initialize

Constructor Details

This class inherits a constructor from Sipity::Runners::BaseRunner

Instance Method Details

#run(sip_id:, identifier: nil) ⇒ Object


29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/runners/sipity/runners/doi_runners.rb', line 29

def run(sip_id:, identifier: nil)
  sip = repository.find_sip(sip_id)
  form = repository.build_assign_a_doi_form(sip: sip, identifier: identifier)
  authorization_layer.enforce!(submit?: form) do
    if repository.submit_assign_a_doi_form(form, requested_by: current_user)
      # TODO: Should this be the form or the sip? Likely the form, but
      # the controller implementations assume the sip
      callback(:success, sip, form.identifier)
    else
      callback(:failure, form)
    end
  end
end