/memory_dump

Easily create memory dumps anywhere and at any time in your Ruby projects

Primary LanguageRuby

What?

By using Ruby's Bindings, you can find a lot of stuff :-)

Usage

After requiring memory_dump, insert the following line anywhere in your code:

dump{}

This will give you a nested Hash containing most variables accessible from where you called it, as well as a few other interesting tidbits:

{:instance_variables=>{"@instance_variable"=>"instance var's value"},
 :class=>YourClass,
 :local_variables=>{"local"=>"local var's value"},
 :class_variables=>{"@@class_variable"=>"class var's value"},
 :ancestors=>[YourClass, YourMom, Object],
 :backtrace=>['you_get_the_drift.rb']}

If you're ready for an explosion of (very interesting) information, call it in verbose mode:

dump(:verbose){}
dump(:v){}

Included in the previous hash will be two additional hashes of name-value pairs. One containing all the global variables and the other one containing all the accessible constants.

Note: all keys for buckets generated by the tool are symbols. All other keys (variable names, constants, etc) are strings.

Other stuff

To know more about bindings, check out