Module: NoSE::Loader::ClassMethods
- Defined in:
- lib/nose/util.rb
Overview
Add a class method to load class instances from file
Instance Method Summary collapse
-
#load(name) ⇒ Object
Load a class with the given name from a directory specified by the LOAD_PATH class constant.
Instance Method Details
#load(name) ⇒ Object
Load a class with the given name from a directory specified by the LOAD_PATH class constant
278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/nose/util.rb', line 278 def load(name) if File.exist? name filename = name else path = const_get(:LOAD_PATH) filename = File. "../../../#{path}/#{name}.rb", __FILE__ end source_code = File.read(filename) instance = binding.eval source_code, filename instance.instance_variable_set :@source_code, source_code instance end |