Module: Pry::Memory::Hook
Overview
Class responsible for adding hook to pry
Constant Summary collapse
- PRY_HOOK =
:after_eval- HOOK_NAME =
'pry-memory'
Instance Method Summary collapse
Instance Method Details
#register ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pry/memory/hook.rb', line 15 def register Pry.hooks.add_hook PRY_HOOK, HOOK_NAME do |result, pry_instance| if result pry_binding = pry_instance.current_binding variable_name = Pry::Memory::Strategy.variable_name pry_binding.local_variable_set(variable_name, result) Pry::Memory::Strategy.next! end end end |
#unregister ⇒ Object
26 27 28 |
# File 'lib/pry/memory/hook.rb', line 26 def unregister Pry.hooks.delete_hook(PRY_HOOK, HOOK_NAME) end |