Created
November 19, 2012 06:56
-
-
Save swarley/4109319 to your computer and use it in GitHub Desktop.
pry-hack/load
This file contains hidden or 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
| [2] pry(main)> require "pry/hack/load" | |
| => true | |
| [3] pry(main)> Pry.add_hack(:method, :peek_ivar, Pry::Hackage::Hack.new(/@(.+?)$/) { replace_with "instance_variable_get(:@#{capture 1})" }) | |
| => #<Pry::Hackage::Hack:0x00000002540838 | |
| @CODE=#<Proc:0x000000025407e8@(pry):3>, | |
| @PATTERN=/@(.+?)$/> | |
| [4] pry(main)> Pry.config.hack.enabled = true | |
| => true | |
| [5] pry(main)> class Test; def initialize; @ivar = :defined; end; end | |
| => nil | |
| [6] pry(main)> load "./t/test.rb" | |
| => true | |
| [7] pry(main)> $k | |
| => #<Test:0x0000000281edc0 @ivar=:defined> | |
| [8] pry(main)> cat ./t/test.rb | |
| $k = Test.new | |
| $k.@ivar | |
| [9] pry(main)> $k | |
| => #<Test:0x0000000281edc0 @ivar=:defined> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pasali po?