Class: Sipity::Runners::CitationRunners::Create

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

Overview

Responsible for building, validating, and submitting the form.

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:, attributes: {}) ⇒ Object


44
45
46
47
48
49
50
51
52
53
54
# File 'app/runners/sipity/runners/citation_runners.rb', line 44

def run(sip_id:, attributes: {})
  sip = repository.find_sip(sip_id)
  form = repository.build_assign_a_citation_form(attributes.merge(sip: sip))
  authorization_layer.enforce!(submit?: form) do
    if repository.submit_assign_a_citation_form(form, requested_by: current_user)
      callback(:success, sip)
    else
      callback(:failure, form)
    end
  end
end