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


# in file test.rb

class MyClass; end
p MyClass.classdef_in_file # => test.rb


Regards,

   Michael