実行中Rubyプログラムのbinding.pryを全て無効にする
Pry version: 0.9.12.4 on Ruby 2.1.0.
これだけ
pry(main)> disable-pry
どんな機能かというと
pry(main)> help disable-pry Usage: disable-pry After this command is run any further calls to pry will immediately return `nil` without interrupting the flow of your program. This is particularly useful when you've debugged the problem you were having, and now wish the program to run to the end. As alternatives, consider using `exit!` to force the current Ruby process to quit immediately; or using `edit-method -p` to remove the `binding.pry` from the code.
ということらしい。
例えばループ中とかshared_examplesとかでbinding.pryしたとき、これを使えば目的の動作を確認した後にぐぬぬってならなくて済みますね。
ただ、binding.pry
がnil
を返す動作は変わらないのでそこだけ注意です。
他の方法としては、exit!
を使うか、edit-method -p
でbinding.pry
を削除してくれと書いてありますね。
ちなみに、edit-method
すると "DISABLED: Use edit
instead." と怒られるので、指示に従ってedit -p method-name
とでもしておきましょう。