Class: Sipity::Runners::CitationRunners::New

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

Overview

Responsible for responding with the correct form for the sip's citation

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



26
27
28
29
30
31
32
33
34
35
36
# File 'app/runners/sipity/runners/citation_runners.rb', line 26

def run(sip_id:)
  sip = repository.find_sip(sip_id)
  form = repository.build_assign_a_citation_form(sip: sip)
  authorization_layer.enforce!(submit?: form) do
    if repository.citation_already_assigned?(sip)
      callback(:citation_assigned, sip)
    else
      callback(:citation_not_assigned, form)
    end
  end
end