From: Pit Capitain Date: 2007-03-14T02:00:30+09:00 Subject: Re: get object from its object-specific class? Pit Capitain schrieb: > The only gotchas are that you should make sure that the original #to_s > method is used, and you'd have to add a special case for singleton > classes of modules: > > p class << Module; self; end # => # Tom, sorry for the noise, but you can create pathological situations where you can't get at the module via its name: obj = M = Module.new obj.to_s Object.class_eval do remove_const "M" end p class << obj; self; end # => # p Object.const_get("M") rescue p $! # => # Maybe someone doing this deserves some troubles... Regards, Pit