Last active
May 12, 2020 17:59
-
-
Save havenwood/c42f866040db28af95a83823cc2aff1e to your computer and use it in GitHub Desktop.
A snippet to add to your .pryrc so refinements work at top level
This file contains 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
Tempfile.new('pry-binding').tap do |binding_chord| | |
binding_chord << 'Pry.toplevel_binding = binding' | |
binding_chord.close | |
load binding_chord.path | |
ensure | |
binding_chord.unlink | |
end |
This file contains 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
# derived from al203-cr's solution in the #ruby IRC channel | |
Pry.hooks.add_hook :when_started, :context_switch do |_output, _binding, pry| | |
pry.binding_stack = [TOPLEVEL_BINDING] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment