From: Sea&Gull Date: 2005-01-29T01:50:56+09:00 Subject: Re: : How can I find the filename where a class is defined? Michael Neumann wrote: > George Moschovitis wrote: > >>> Since a class can be spread over multiple files, you have to define >> >> >> which >> >>> one(s) you want to get. >> >> >> >> My class is defined in one file only. I dont want a general solution. I >> want a solution for classes defined in a single file. Any other ideas? > > > Yes, that's what I needed last night, too (and some month ago where I > considered Wee+templating). > > class Object > class << self > attr_accessor :classdef_in_file > > alias __old_inherited inherited > def inherited(klass) > klass.classdef_in_file = caller.last.split(":").first > __old_inherited(klass) > end > end > end Don't you forget private :inherited ? :-) Also I would like to ask why you used "class Object" but not "class Class"? There are some reasons I haven't seen? -- s&g