I'd like to access the source of a class like so:
# Module inside file1.rb
module MetaFoo
class << Object
def bar
# here I'd like to access the source location of the Foo class definition
# which should result in /path/to/file2.rb
end
end
end
# Class inside another file2.rb
class Foo
bar
end
I could do something bad like:
self.send(:caller)
and try to parse the output, or even:
class Foo
bar __FILE__
end
But that's not, want I want, I had the hope there is a more elegant solution for that.
Any hints are welcome.