aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_support_core_extensions.md
diff options
context:
space:
mode:
authorUriel Katz <uriel.katz@gmail.com>2012-11-17 02:05:53 +0200
committerUriel Katz <uriel.katz@gmail.com>2012-12-01 14:00:16 +0200
commit9ee0ffb3602720fceaecc2fbae1c932341482e31 (patch)
tree9a3f7c9fab2bfce6c1ceb136e72be133f58fc8df /guides/source/active_support_core_extensions.md
parent005d910624bbfa724b638426a000c8074d4201a2 (diff)
downloadrails-9ee0ffb3602720fceaecc2fbae1c932341482e31.tar.gz
rails-9ee0ffb3602720fceaecc2fbae1c932341482e31.tar.bz2
rails-9ee0ffb3602720fceaecc2fbae1c932341482e31.zip
Patched Marshal#load to work with constant autoloading (active_support/dependecies.rb) (issue #8167)
Diffstat (limited to 'guides/source/active_support_core_extensions.md')
-rw-r--r--guides/source/active_support_core_extensions.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md
index e6f2db2a2d..9fca3d585b 100644
--- a/guides/source/active_support_core_extensions.md
+++ b/guides/source/active_support_core_extensions.md
@@ -3720,6 +3720,27 @@ 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.
+
+For example, ActiveSupport uses this method to read from cache(in FileStore):
+
+```ruby
+File.open(file_name) { |f| Marshal.load(f) }
+```
+
+If Marshal#load didn't support constant autoloading then various caching stores wouldn't too.
+
+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.
+
+NOTE: Defined in `active_support/core_ext/marshal.rb`.
+
Extensions to `Logger`
----------------------