Class: Sipity::Runners::SipRunners::Create

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

Overview

Responsible for creating and persisting a new 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(attributes:) ⇒ Object


23
24
25
26
27
28
29
30
31
32
33
# File 'app/runners/sipity/runners/sip_runners.rb', line 23

def run(attributes:)
  form = repository.build_create_sip_form(attributes: attributes)
  authorization_layer.enforce!(create?: form) do
    sip = repository.submit_create_sip_form(form, requested_by: current_user)
    if sip
      callback(:success, sip)
    else
      callback(:failure, form)
    end
  end
end