Is there interest in this? : get object from its object-specific class?

R

Rick DeNatale

The following is the culmination of a discussion on ruby-talk from a
few days ago.

Someone asked if there was a way to find the instance of a singleton
class if you only had the class. After positing a solution using
ObjectSpace.each_object, I then wrote a small extension to get it via
the hidden __attached__ instance variable.

I was then asked to submit it to ruby-core, although I'm not sure
whether it's a problem which needs to be addressed in the core.

But just in case here's the discussion. If there's interest, I could
come up with a patch for 1.8.5, 1.8.6, and maybe 1.9.

Actually, you mean Pit. He did the benchmarks. This is definitely the
way to do it right though. I would submit this to ruby-core mailing
list and see how it takes over there.

T.


--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

IPMS/USA Region 12 Coordinator
http://ipmsr12.denhaven2.com/

Visit the Project Mercury Wiki Site
http://www.mercuryspacecraft.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top