awesome-print / awesome_print

Pretty print your Ruby objects with style -- in full color and with proper indentation
http://github.com/michaeldv/awesome_print
MIT License
4.07k stars 454 forks source link

Remove dependence on `#method` being defined #423

Open amomchilov opened 1 year ago

amomchilov commented 1 year ago

This PR tweaks how #405 was implemented, so that it achieves the same effect, but without needing the inspected object to implement #method.

This is done by using Kernel's implementation of #method, and using it with any kind of object.

I ran into this from trying to make a BasicObject subclass awesome-printable. To make it work, you need to define #ai, #class, #object_id and #method. After this change, only the first of those 3 are necessary.