Module: Byebug::Skipper::Pry::ProcessorHacks

Defined in:
lib/byebug/skipper/pry.rb

Overview

This is a monkey patch for Byebug::PryProcessor in order to add extra Byebug commands to Pry. This needs to be overriden because there is a hard-coded whitelist of ‘action` values inside, and I need to add custom actions.

Instance Method Summary collapse

Instance Method Details

#perform(action, options = {}) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/byebug/skipper/pry.rb', line 55

def perform(action, options = {})
  # If it's not one of our commands, short circuit and use the typical
  # behaviour.
  command = Byebug::Skipper::Pry::COMMANDS.find { _1.fetch(:cmd) == action.to_s }
  return super unless command

  # Call the Byebug command objects directly. This seems kind of fragile to
  # me, but I don't see any better options.
  Byebug::Skipper.const_get("#{command.fetch(:const_name)}Command")
    .new(self, action.to_s)
    .execute

  # This shows the REPL again, preventing execution from continuing.
  resume_pry unless command.fetch(:continues?)
end