"David Douthitt" <DDouthitt / cuna.com> writes:

> Is there any way to manipulate the list of processes set to run at
> execution by at_exit? Can it be cleared out or reset? Can processes be
> removed?

Well, you could write your own. This example uses a couple of 1.5
features (class instance variables and slices) but you could do the
same under 1.4


     class AtExit
       @@thingsToRun = []
       @@names = {}

       def AtExit.run(name, &thing)
         AtExit.delete(name)
         @@names[name] = @@thingsToRun.size
         @@thingsToRun << thing
       end

       def AtExit.delete(name)
         index = @@names[name]
         if index
           @@thingsToRun.delete_at(index)
           @@names.delete(name)
         end
       end

       def AtExit.runHandlers
         @@thingsToRun.reverse_each { |thing| thing.call }
       end

       at_exit { AtExit.runHandlers }
     end

     AtExit.run("goofy") { puts "Dave" }
     AtExit.run("minnie") { puts "Says" }
     AtExit.run("mickey") { puts "Regards" }
     AtExit.delete("minnie")

  # =>

     Regards
     Dave