diff options
author | Xavier Noria <fxn@hashref.com> | 2014-12-15 10:21:27 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2014-12-15 10:22:30 +0100 |
commit | 4ffa699799758b49ba4c541494dd5fc84a9766d2 (patch) | |
tree | b573bb019572892d7c0ee693048971e4e49442b3 /guides/source | |
parent | 5c37c9a5c09f9f09fa5596da07f78519a1719b9f (diff) | |
download | rails-4ffa699799758b49ba4c541494dd5fc84a9766d2.tar.gz rails-4ffa699799758b49ba4c541494dd5fc84a9766d2.tar.bz2 rails-4ffa699799758b49ba4c541494dd5fc84a9766d2.zip |
autoloading guide: Kernel#autoload -> Module#autoload [ci skip]
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/constant_autoloading_and_reloading.md | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/guides/source/constant_autoloading_and_reloading.md b/guides/source/constant_autoloading_and_reloading.md index e01545e3af..1a1df59095 100644 --- a/guides/source/constant_autoloading_and_reloading.md +++ b/guides/source/constant_autoloading_and_reloading.md @@ -15,7 +15,7 @@ After reading this guide, you will know: * How constant reloading works -* That autoloading is not based on `Kernel#autoload` +* That autoloading is not based on `Module#autoload` * Solutions to common autoloading gotchas @@ -645,24 +645,24 @@ what changed since dependencies between classes makes that really tricky. Instead, everything is wiped. -Kernel#autoload isn't Involved +Module#autoload isn't Involved ------------------------------ -`Kernel#autoload` provides a lazy way to load constants that is fully integrated +`Module#autoload` provides a lazy way to load constants that is fully integrated with the Ruby constant lookup algorithms, dynamic constant API, etc. It is quite transparent. Rails internals make extensive use of it to defer as much work as possible from the boot process. But constant autoloading in Rails is **not** implemented with -`Kernel#autoload`. +`Module#autoload`. -One possible implementation based on `Kernel#autoload` would be to walk the +One possible implementation based on `Module#autoload` would be to walk the application tree and issue `autoload` calls that map existing file names to their conventional contant name. There are a number of reasons that prevent Rails from using that implementation. -For example, `Kernel#autoload` is only capable of loading files using `require`, +For example, `Module#autoload` is only capable of loading files using `require`, so reloading would not be possible. Not only that, it uses an internal `require` which is not `Kernel#require`. @@ -672,7 +672,7 @@ again. Also, it doesn't support qualified names, so files with namespaces should be interpreted during the walk tree to install their own `autoload` calls, but those files could have constant references not yet configured. -An implementation based on `Kernel#autoload` would be awesome but, as you see, +An implementation based on `Module#autoload` would be awesome but, as you see, at least as of today it is not possible. Constant autoloading in Rails is implemented with `Module#const_missing`, and that's why it has its own contract, documented in this guide. |