Class: Fig::AtExit

Inherits:
Object
  • Object
show all
Defined in:
lib/fig/at_exit.rb

Overview

This exists because standard Kernel#at_exit blocks don’t get run before Kernel#exec.

Class Method Summary collapse

Class Method Details

.add(&block) ⇒ Object



6
7
8
9
10
# File 'lib/fig/at_exit.rb', line 6

def self.add(&block)
  EXIT_PROCS << block

  return
end

.executeObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fig/at_exit.rb', line 12

def self.execute()
  EXIT_PROCS.each do
    |proc|

    begin
      proc.call()
    rescue StandardError => exception
      $stderr.puts(
        [
          %q<Got exception from "at exit" processing.>,
          exception.message,
          exception.backtrace
        ].flatten.join("\n")
      )
    end
  end

  return
end