I have a module MyModule . I dynamically load classes into it. How can I get a list of classes defined in its namespace?
Example:
def load_plugins Dir.glob(File.dirname(__FILE__) + '/plugins/*.rb') do |f| MyModule.class_eval File.read(f) end
I have to say that every f contains something like "class Foo; end".
You can also think of it this way: in Rails, how could I programmatically find all the classes defined in the ActiveRecord module?
ruby metaprogramming
joshuaxls May 7, '09 at 6:18 2009-05-07 06:18
source share