Module: FakeFS::Require::Autoload
- Included in:
- Module
- Defined in:
- lib/fakefs/require.rb
Instance Method Summary collapse
-
#fakefs_autoload(const, file) ⇒ Object
Faked #autoload (see Module#autoload).
-
#fakefs_autoload?(const) ⇒ Boolean
Faked #autoload? (see Module#autoload?).
-
#fakefs_const_missing(name) ⇒ Object
Implementation of #const_missing, catches autoload cases.
Instance Method Details
#fakefs_autoload(const, file) ⇒ Object
Faked #autoload (see Module#autoload)
137 138 139 140 |
# File 'lib/fakefs/require.rb', line 137 def fakefs_autoload const, file Require.autoloadable[self] ||= {} Require.autoloadable[self][const] = file end |
#fakefs_autoload?(const) ⇒ Boolean
Faked #autoload? (see Module#autoload?)
143 144 145 146 |
# File 'lib/fakefs/require.rb', line 143 def fakefs_autoload? const hsh = Require.autoloadable[self] return hsh[const] if hsh end |
#fakefs_const_missing(name) ⇒ Object
Implementation of #const_missing, catches autoload cases
149 150 151 152 153 154 155 156 157 |
# File 'lib/fakefs/require.rb', line 149 def fakefs_const_missing name file = autoload? name if file require file return const_get name if const_defined? name end parent = (self == Object) ? "" : self.to_s + "::" raise NameError, "uninitialized constant #{parent + name.to_s}", caller end |