最佳答案
I have a module MyModule
. I dynamically load classes into it. How can I get a list of the classes defined within its namespace?
Example:
def load_plugins
Dir.glob(File.dirname(__FILE__) + '/plugins/*.rb') do |f|
MyModule.class_eval File.read(f)
end
# now how can I find the new classes I've loaded into MyModule?
end
I should say that each f
contains something like "class Foo; end".
You can also think of it like this: in Rails, how could I programatically find all classes defined within the ActiveRecord module?