Return to Snippet

Revision: 17985
at September 18, 2009 16:04 by blasterpal


Initial Code
#assumes all modules follow UpperUpper format with file name lower_lower.rb.
Dir[File.join(File.dirname(__FILE__), '..', 'lib') + "**/*.rb"].each {|file| 
      require file
      include self.class.const_get(File.basename(file).gsub('.rb','').split("_").map{|ea| ea.capitalize}.to_s)
}

Initial URL
www.rubyslacker.com

Initial Description
This assumes the modules names are CamelCase and not UPPERCASE.

Initial Title
Dynamically include all modules in a directory

Initial Tags
directory

Initial Language
Ruby