Created
January 26, 2012 06:37
-
-
Save bhelx/1681396 to your computer and use it in GitHub Desktop.
Pry trick
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 'pry' | |
class Object | |
LABELS = [:label1, :label2] | |
def breakpt(label, target=self) | |
LABELS.include?(label) ? Pry.start(target) : nil | |
end | |
end | |
class Greeter | |
def initialize | |
@age = 42 | |
@name = "Hello World!" | |
end | |
def greet | |
binding.breakpt(:ignored_label) | |
puts "Hello #{@name}" | |
binding.breakpt(:label1) | |
puts "Age #{@age}" | |
end | |
end | |
g = Greeter.new | |
g.greet | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment