Created
November 18, 2012 22:39
-
-
Save swarley/4107917 to your computer and use it in GitHub Desktop.
pry/pry-hack
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
[1] pry(main)> load "./hack.rb" | |
/usr/local/lib/ruby/gems/1.9.1/gems/reg-0.4.8/regdeferred.rb:53: warning: undefining `object_id' may cause serious problems | |
/usr/local/lib/ruby/gems/1.9.1/gems/reg-0.4.8/regdeferred.rb:53: warning: undefining `object_id' may cause serious problems | |
/usr/local/lib/ruby/gems/1.9.1/gems/reg-0.4.8/regdeferred.rb:53: warning: undefining `object_id' may cause serious problems | |
/usr/local/lib/ruby/gems/1.9.1/gems/reg-0.4.8/regdeferred.rb:53: warning: undefining `object_id' may cause serious problems | |
/usr/local/lib/ruby/gems/1.9.1/gems/reg-0.4.8/regdeferred.rb:53: warning: undefining `object_id' may cause serious problems | |
^[[A=> true | |
[2] pry(main)> Pry.add_hack(:method, Pry::Hackage::Hack.new(/^\@([A-Za-z0-9_]+)$/) { replace_with "instance_variable_get(:@#{capture 1})" }) | |
=> 28680540 | |
[3] pry(main)> class Test; def initialize; @o = 1; end; end | |
=> nil | |
[4] pry(main)> k = Test.new | |
=> #<Test:0x00000002e114f8 @o=1> | |
[5] pry(main)> Pry.config.hack.enabled = true | |
=> true | |
[6] pry(main)> k.@o | |
=> 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment