From: Adam Prescott Date: 2011-03-26T07:29:59+09:00 Subject: Re: How to get the value of a singleton class? --0016e65a0b6ce14f7a049f560bcc Content-Type: text/plain; charset=UTF-8 On Fri, Mar 25, 2011 at 12:52 PM, Robert Dober wrote: > Now if you were looking for a way to get from a singleton class of an > object to the object itself, I am not sure that this is possible. > This should do the trick: >> s = "" => "" >> class << s >> def test >> 1 >> end >> end => nil >> s.test => 1 >> meta = (class << s; self; end) => #> >> ObjectSpace.each_object(meta).to_a => [""] >> _.first.object_id => 69092310 >> s.object_id => 69092310 --0016e65a0b6ce14f7a049f560bcc--