/debugging_procs.rb Secret
Created
February 23, 2012 15:05
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'ruby-debug' | |
def example | |
debugger | |
puts "Hello, I'm example" | |
end | |
def add_listener(&block) | |
$listeners ||= Array.new | |
$listeners.push(&block) | |
end | |
def ping_listeners | |
$listeners.map(&:call) | |
end | |
# Drops into the debugger as expected | |
example | |
# Erm... WAT!? | |
add_listener(&method(:example)) | |
ping_listeners |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment