Class: Sipity::Runners::DoiRunners::Show

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

Overview

Responsible for showing the correct state of the DOI for the given 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:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/runners/sipity/runners/doi_runners.rb', line 9

def run(sip_id:)
  sip = repository.find_sip(sip_id)
  authorization_layer.enforce!(show?: sip) do
    # TODO: Tease out state machine from DoiRecommendation
    if repository.doi_already_assigned?(sip)
      callback(:doi_already_assigned, sip)
    elsif repository.doi_request_is_pending?(sip)
      callback(:doi_request_is_pending, sip)
    else
      callback(:doi_not_assigned, sip)
    end
  end
end