Method: WrapInModule::Script#require
- Defined in:
- lib/wrap_in_module.rb
#require(feature) ⇒ Object
Analogous to Kernel#require. First tries the local dir, then falls back to Kernel#require. Will load a given feature only once.
Note that extensions (*.so, *.dll) can be required in the global scope, as usual, but not in the local scope. (This is not much of a limitation in practice–you wouldn’t want to load an extension more than once.) This implementation falls back to Kernel#require when the argument is an extension or is not found locally.
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/wrap_in_module.rb', line 77 def require(feature) unless @__loaded_features[feature] @__loaded_features[feature] = true file = File.join(@__dir, feature) file += ".rb" unless /\.rb$/ =~ file load_in_module(file) end rescue MissingFile @__loaded_features[feature] = false super end |