4 ms·
Won't the binding then be your monkey patched debug method on kernel instead of where you called it from?
by lparry 10y ago
Won't the binding then be your monkey patched debug method on kernel instead of where you called it from?
- sirn 10y agoYes. irb(main):008:0> x = "1" => "1" irb(main):009:0> debug [1] pry(main)> x NameError: undefined local variable or method `x' for main:Object from (pry):1:in `debug' If you really want to do this, you can use binding_of_caller[1] to create binding object (`Kernel.binding`) up in the call stack: require 'binding_of_caller' require 'pry' module Kernel def debug binding.of_caller(1).pry end end Then: irb(main):008:0> x = "1" => "1" irb(main):009:0> debug [1] pry(main)> x => "1" [1]: https://github.com/banister/binding_of_caller https://github.com/banister/binding_of_caller