aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_support_core_extensions.md
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2012-12-01 14:18:25 +0100
committerXavier Noria <fxn@hashref.com>2012-12-01 14:18:25 +0100
commit0dc1417185aeeec333e7ead0bab340e4e188df4e (patch)
treef74a7907c3267ca11c39f5aa20682a4d3a240e75 /guides/source/active_support_core_extensions.md
parent60edeceda3317043a43e3b9aa9087dec4b6a81fb (diff)
downloadrails-0dc1417185aeeec333e7ead0bab340e4e188df4e.tar.gz
rails-0dc1417185aeeec333e7ead0bab340e4e188df4e.tar.bz2
rails-0dc1417185aeeec333e7ead0bab340e4e188df4e.zip
copy-edits the docs of 9ee0ffb
Diffstat (limited to 'guides/source/active_support_core_extensions.md')
-rw-r--r--guides/source/active_support_core_extensions.md12
1 files changed, 5 insertions, 7 deletions
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md
index 9fca3d585b..79ff945495 100644
--- a/guides/source/active_support_core_extensions.md
+++ b/guides/source/active_support_core_extensions.md
@@ -3721,23 +3721,21 @@ The auxiliary file is written in a standard directory for temporary files, but y
NOTE: Defined in `active_support/core_ext/file/atomic.rb`.
Extensions to `Marshal`
---------------------
+-----------------------
### `load`
-Unpatched Marshal#load doesn't call constant_missing so in order to support ActiveSupport constant autoloading load is patched using alias_method_chain.
-
-The method accepts the same arguments as unpatched Marshal#load and the result of calling it will be the same.
+Active Support adds constant autoloading support to `load`.
-For example, ActiveSupport uses this method to read from cache(in FileStore):
+For example, the file cache store deserializes this way:
```ruby
File.open(file_name) { |f| Marshal.load(f) }
```
-If Marshal#load didn't support constant autoloading then various caching stores wouldn't too.
+If the cached data refers to a constant that is unknown at that point, the autoloading mechanism is triggered and if it succeeds the desarialization is retried transparently.
-WARNING. If a IO (e.g. a file) is used as source it needs to respond to rewind (which a normal file does) because if an exception is raised calling the original Marshal#load the file will be exhausted.
+WARNING. If the argument is an `IO` it needs to respond to `rewind` to be able to retry. Regular files respond to `rewind`.
NOTE: Defined in `active_support/core_ext/marshal.rb`.