From: Erik Veenstra Date: 2006-07-25T06:04:25+09:00 Subject: Object to which a meta class belongs? If a singleton class belongs to an object, it should be possible to determine to which object it belongs. Is that possible? I came up with the code below, but it might not be very fast. Thanks. gegroet, Erik V. - http://www.erikveen.dds.nl/ ---------------------------------------------------------------- class Object def metaclass obj = self class << self self end.instance_eval do instance_eval <<-END def belongs_to ObjectSpace._id2ref(#{obj.__id__}) end END self end end end a = "TEST" p a.__id__ p a.metaclass.belongs_to.__id__ ----------------------------------------------------------------