class Pry
def repl(target=TOPLEVEL_BINDING)
-
(Object)
- The target of the Pry session
Parameters:
-
target
(Object, Binding
) -- The receiver of the Pry session
def repl(target=TOPLEVEL_BINDING) target = Pry.binding_for(target) target_self = target.eval('self') exec_hook :before_session, output, target_self # cannot rely on nesting.level as # nesting.level changes with new sessions nesting_level = nesting.size Pry.active_instance = self # Make sure special locals exist target.eval("_pry_ = Pry.active_instance") target.eval("_ = Pry.last_result") break_level = catch(:breakout) do nesting.push [nesting.size, target_self, self] loop do rep(target) end end nesting.pop exec_hook :after_session, output, target_self # keep throwing until we reach the desired nesting level if nesting_level != break_level throw :breakout, break_level end target_self end