Method: Interaktor#run!

Defined in:
lib/interaktor.rb

#run!Object

Invoke an Interaktor instance along with all defined hooks, typically used internally by ‘.call!`. After successful invocation of the interaktor, the instance is tracked within the interaction. If the interaction is failed or any error is raised, the interaction is rolled back. This method behaves identically to `#run` with one notable exception - if the interaction is failed during the invocation of the interaktor, `Interaktor::Failure` is raised.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/interaktor.rb', line 84

def run!
  with_hooks do
    catch(:early_return) do
      call
    end

    if self.class.required_success_attributes.any? && !@interaction.success_args
      raise Interaktor::Error::MissingExplicitSuccessError.new(self, self.class.required_success_attributes)
    end

    @interaction.called!(self)
  end
rescue
  @interaction.rollback!
  raise
end