From: Rob Pitt Date: 2008-03-22T17:30:03+09:00 Subject: Re: get object from its object-specific class? No, this was deliberate. Maybe it was a mistake... My singleton_parent retrieves __attached__, but I was saying Pit's instance_of_singleton_class_2 method works as a replacement for this where as ObjectSpace does not. Here, I've refactored the instance_of_singleton_class_2 into a singleton_parent method for you: def singleton_parent # __instance_variable_get__( '__attached__' ) return nil unless is_a? Class obj = nil class_eval do if instance_methods( false ).include?( "singleton_method_added" ) org = instance_method( :singleton_method_added ) remove_method( :singleton_method_added ) end define_method( :singleton_method_added ) do |m| obj = self end remove_method( :singleton_method_added ) define_method( :singleton_method_added, org) if org end obj end > I think you forgot to define singleton_parent. > > > David -- Posted via http://www.ruby-forum.com/.