Method: ActiveSupport::ExecutionWrapper.run!

Defined in:
activesupport/lib/active_support/execution_wrapper.rb

.run!(reset: false) ⇒ Object

Run this execution.

Returns an instance, whose complete! method must be invoked after the work has been performed.

Where possible, prefer wrap.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'activesupport/lib/active_support/execution_wrapper.rb', line 66

def self.run!(reset: false)
  if reset
    lost_instance = IsolatedExecutionState.delete(active_key)
    lost_instance&.complete!
  else
    return Null if active?
  end

  new.tap do |instance|
    success = nil
    begin
      instance.run!
      success = true
    ensure
      instance.complete! unless success
    end
  end
end