Methods
C
R
T
W
Included Modules
Attributes
[RW] active
Class Public methods
register_hook(hook, outer: false)

Register an object to be invoked during both the run and complete steps.

hook.complete will be passed the value returned from hook.run, and will only be invoked if run has previously been called. (Mostly, this means it won't be invoked if an exception occurs in a preceding to_run block; all ordinary to_complete blocks are invoked in that situation.)

   # File activesupport/lib/active_support/execution_wrapper.rb
50 def self.register_hook(hook, outer: false)
51   if outer
52     to_run RunHook.new(hook), prepend: true
53     to_complete :after, CompleteHook.new(hook)
54   else
55     to_run RunHook.new(hook)
56     to_complete CompleteHook.new(hook)
57   end
58 end
run!()

Run this execution.

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

Where possible, prefer wrap.

   # File activesupport/lib/active_support/execution_wrapper.rb
66 def self.run!
67   if active?
68     Null
69   else
70     new.tap do |instance|
71       success = nil
72       begin
73         instance.run!
74         success = true
75       ensure
76         instance.complete! unless success
77       end
78     end
79   end
80 end
to_complete(*args, &block)
   # File activesupport/lib/active_support/execution_wrapper.rb
21 def self.to_complete(*args, &block)
22   set_callback(:complete, *args, &block)
23 end
to_run(*args, &block)
   # File activesupport/lib/active_support/execution_wrapper.rb
17 def self.to_run(*args, &block)
18   set_callback(:run, *args, &block)
19 end
wrap()

Perform the work in the supplied block as an execution.

   # File activesupport/lib/active_support/execution_wrapper.rb
83 def self.wrap
84   return yield if active?
85 
86   instance = run!
87   begin
88     yield
89   ensure
90     instance.complete!
91   end
92 end
Instance Public methods
complete!()

Complete this in-flight execution. This method must be called exactly once on the result of any call to run!.

Where possible, prefer wrap.

    # File activesupport/lib/active_support/execution_wrapper.rb
118 def complete!
119   run_callbacks(:complete)
120 ensure
121   self.class.active.delete Thread.current
122 end