Class: Byebug::Skipper::StepsCommand::HackyProcessor
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Byebug::Skipper::StepsCommand::HackyProcessor
- Defined in:
- lib/byebug/skipper/steps_command.rb
Overview
We need to hijack the #at_line method of the processor, to prevent it from running the REPL when we want it to skip that frame. Sneakily replaces the processor with this wrapped/delegated version, and then unwraps/undelegates when no longer necessary.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.hack_into(context) ⇒ Object
27 28 29 30 31 |
# File 'lib/byebug/skipper/steps_command.rb', line 27 def self.hack_into(context) hack = new(context.send(:processor)) context.instance_variable_set(:@processor, hack) hack.skip_this_frame! end |
Instance Method Details
#at_line ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/byebug/skipper/steps_command.rb', line 42 def at_line if Byebug::Skipper.skip?(context.location) skip_this_frame! # don't stop, keep running else unhack! super # will stop and show REPL end end |
#skip_this_frame! ⇒ Object
37 38 39 40 |
# File 'lib/byebug/skipper/steps_command.rb', line 37 def skip_this_frame! context.step_into(1, context.frame.pos) proceed! end |
#unhack! ⇒ Object
33 34 35 |
# File 'lib/byebug/skipper/steps_command.rb', line 33 def unhack! context.instance_variable_set(:@processor, __getobj__) end |