Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/autoload.rb
Instance Method Summary collapse
-
#autoload(cname, path) ⇒ String
Module/Class level autoload method.
-
#const_missing(name) ⇒ Object
private
Check the $AUTOLOAD table for a ‘[self, name]` entry.
- #const_missing_without_autoload ⇒ Object private
Instance Method Details
#autoload(cname, path) ⇒ String
Module/Class level autoload method.
52 53 54 |
# File 'lib/autoload.rb', line 52 def autoload(cname, path) $AUTOLOAD[[self, cname.to_sym]] << path end |
#const_missing(name) ⇒ Object (private)
Check the $AUTOLOAD table for a ‘[self, name]` entry. If present, require file and try to get the constant again.
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/autoload.rb', line 67 def const_missing(name) if paths = $AUTOLOAD.delete([self, name]) paths.each do |path| require(path) end const_missing_without_autoload(name) unless const_defined?(name) const_get(name) else const_missing_without_autoload(name) end end |
#const_missing_without_autoload ⇒ Object (private)
58 |
# File 'lib/autoload.rb', line 58 alias :const_missing_without_autoload :const_missing |