Class: Class
- Inherits:
-
Object
- Object
- Class
- Defined in:
- lib/memory_leak_helper.rb
Overview
Hack the ‘Class’-class in order to get callbacks when objects are created.
Instance Method Summary collapse
-
#__memory_leak_helper_original_new ⇒ Object
Alias the original new-method to a method that hopefully will never be found.
-
#new(*args, &blk) ⇒ Object
Make a new method that will be called whenever an object is created.
Instance Method Details
#__memory_leak_helper_original_new ⇒ Object
Alias the original new-method to a method that hopefully will never be found.
87 |
# File 'lib/memory_leak_helper.rb', line 87 alias __memory_leak_helper_original_new new |
#new(*args, &blk) ⇒ Object
Make a new method that will be called whenever an object is created. Register that object with ‘Memory_leak_helper’ and return it as it normally would.
90 91 92 93 94 95 96 |
# File 'lib/memory_leak_helper.rb', line 90 def new(*args, &blk) mlh = Memory_leak_helper::INSTANCE obj = __memory_leak_helper_original_new(*args, &blk) mlh.register_object(:obj => obj, :caller => caller) if mlh return obj end |