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



8
9
10
11
12
# File 'lib/fig/at_exit.rb', line 8

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

  return
end

.executeObject



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

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