Ruby: Locate class definition at run time?

Posted by Thor Thurn on Stack Overflow See other posts from Stack Overflow or by Thor Thurn
Published on 2010-04-11T18:30:27Z Indexed on 2010/04/11 18:33 UTC
Read the original article Hit count: 272

Filed under:
|

I'm having an odd probably with rails right now... a class is being defined somewhere, and I can't find it. Grepping for "class ClassName" hasn't managed to locate it, but it's definitely there when I load up the rails console. It's just a vanilla class inheriting from Object with nothing else defined... quite boring. So, what I'd like is a way to figure out where this class constant was originally defined from the rails console. Something to print out the value of '__ FILE __' when this class was declared, in other words. I feel like some type of metaprogramming should make this possible.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about rails