Make it your own

So you've started using pry. You've likely found this article from my previous article Give it a Pry, and your digging Pry. You've already found how quickly the Pry repl becomes second nature, how useful having easy shell access is, and how easily it slices to the heart of your code (I'm assuming). If you're at that point you're probably looking around to see what else you can do. I'll re-iterate a point made in "Give it a Pry", go to the WIKI! There is a ton of documentation that will not only help you understand Pry better, but also help you to shed light on your own code. In this article I'm going to quickly show you how to use commands, which are yet another cool feature provided by Pry.

Commands, a unique solution.

Pry lets you define commands which make the inclusion and execution of arbitrary bits of code trivial[1]. The Pry command structure is unique in that the command methods are executed before normal Ruby code is executed. This is important for reasons you'll see below.

If you are anything like me then your ~/.irbrc file had many top level methods(like below), well with pry these can be transformed into commands.