Method: Module#module_load
- Defined in:
- lib/core/facets/module/module_load.rb
#module_load(path) ⇒ Object Also known as: class_load
Load file directly into module/class namespace.
Please use this with careful consideration. It is best suited to loading plugin-type scripts, and should generally not be used as a substitue for Ruby’s standard load system.
NOTE: This method is not a common core extension and is not loaded automatically when using require 'facets'.
CREDIT: Trans
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/core/facets/module/module_load.rb', line 18 def module_load( path ) if path =~ /^[\/~.]/ file = File.(path) else $LOAD_PATH.each do |lp| file = File.join(lp,path) break if File.exist?(file) file = nil end end raise LoadError, "no such file to load -- #{path}" unless file module_eval(File.read(file)) end |