The self gem adds a
self method to all objects which is useful for debugging
If you're using pry,
gem install pry-self and pry will
automatically require thse
self library on startup.
If you're not using pry,
gem install self.
If you're using Bundler add it to the development section of your Gemfile:
group :development do gem 'self' end
When you are inside pry, you can use the self method on any object to access its instance variables and private methods:
It lets you
- Access instance variables (with tab completion)
- Call private methods (with tab completion)
- Update instance variables (yeah, with tab completion)
 pry(main)> ls mouse private methods: squeak! instance variables: @head @tail @legs  pry(main)> mouse.self.head #<Mouse::Head 0x4567>  pry(main)> mouse.head Undefined method 'head' for #<Mouse 0x4567>  pry(main)> mouse.self.squeak! "Squeak!"  pry(main)> mouse.squeak! NoMethodError private method 'squeak!' called for #<Mouse 0x4567>  pry(main)> mouse.self.tail = Mouse::Tail.new #<Mouse::Tail 0x4567>
This gem throws away the ruby method cache each time you use it. Do not use this in production!
Licensed under the MIT license, bug reports and contributions welcome.