ruby - Is there a way to autoexecute code when Pry is triggered? -


When the code faces automatically code Is there a way to execute?

For example, if I want to execute , then puts "Hey, I'm debugging!" Every time the bindings What is called ?

I find that to look at the code and find something that could be useful, It must be added to gemfile or you might be able to add it to your .pryrc (I do not know if it is called from binding.pry or No). From Jithub it appears:

  # @example `: before_session` Adding a hook for the event. Pry.config.hooks.add_hook (: before_session, say_hi) puts "hello" end   

Edit: Here's an example to register hooks and execute it (i.e. your app init): **

  my_hook = Pry :: hook. NY AD_HOOK (: before_session, say_hi) {puts "hi!" } My_hook.exec_hook (: before_session) # = & gt; Output: "Hello!"    

Comments