ruby objects, classes and eigenclasses
October 29, 2008
while working on a little ruby metaprogramming, i realised i didn’t understand how objects, classes and eigenclasses relate to each other in ruby
_why helped some, but i still wasn’t completely clear
i undertook an investigation, with ruby 1.8.6 ( mri and jruby 1.1.4 ), and ruby 1.9 ( mri )
the two 1.8.6 rubys are consistent with each other, but different from ruby 1.9. method resolution seems to function similarly in both 1.8.6 and 1.9, but eigenclasses are referenced differently
this diagram captures what i found

October 3, 2009 at 3:33 pm
heya, this isn’t bad, but:
* meta-classes are not lazily created in MRI 1.8 or 1.9 (see class.c)
* the superclass of the metaclass of A is not the metaclass of class (it’s the metaclass of Object)
* you miss out many class/eigenclass arrows
An accurate 1.8.6 diagram can be found here:
http://banisterfiend.wordpress.com/2008/11/25/a-complete-ruby-class-diagram/
And an accurate 1.9 diagram can be found here:
http://yugui.jp/images/uploaded/20081214-metahierarchy-00.png