Permalink
Browse files

Small tweaks

Don't define a global run_exit_callbacks method, remove warnings.
  • Loading branch information...
1 parent dc16052 commit 03b709e183261d3b2cd1db66444c58e9f498ac9f @ConradIrwin committed Feb 15, 2014
Showing with 13 additions and 9 deletions.
  1. +13 −9 lib/pry-rescue/kernel_exit_hooks.rb
@@ -1,16 +1,20 @@
-Kernel.class_eval '@@exit_callbacks = []'
-
-Kernel.at_exit { Kernel.run_exit_callbacks }
-
-module Kernel
- def at_exit(&block)
- @@exit_callbacks.push block
+class << PryRescue
+ def exit_callbacks
+ @exit_callbacks ||= []
end
def run_exit_callbacks
Pry::rescue do
- @@exit_callbacks.dup.each &:call
+ exit_callbacks.dup.each(&:call)
end
- TOPLEVEL_BINDING.pry unless PryRescue.any_exception_captured
+ TOPLEVEL_BINDING.pry unless any_exception_captured
+ end
+end
+
+Kernel.at_exit { PryRescue.run_exit_callbacks }
+
+module Kernel
+ def at_exit(&block)
+ PryRescue.exit_callbacks.push block
end
end

0 comments on commit 03b709e

Please sign in to comment.