aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
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 /activesupport/lib
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 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/cache/file_store.rb1
-rw-r--r--activesupport/lib/active_support/cache/mem_cache_store.rb1
-rw-r--r--activesupport/lib/active_support/core_ext/marshal.rb21
3 files changed, 23 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb
index 2c1ad60d44..8e265ad863 100644
--- a/activesupport/lib/active_support/cache/file_store.rb
+++ b/activesupport/lib/active_support/cache/file_store.rb
@@ -1,3 +1,4 @@
+require 'active_support/core_ext/marshal'
require 'active_support/core_ext/file/atomic'
require 'active_support/core_ext/string/conversions'
require 'uri/common'
diff --git a/activesupport/lib/active_support/cache/mem_cache_store.rb b/activesupport/lib/active_support/cache/mem_cache_store.rb
index 17450fe4d0..712db2c75a 100644
--- a/activesupport/lib/active_support/cache/mem_cache_store.rb
+++ b/activesupport/lib/active_support/cache/mem_cache_store.rb
@@ -6,6 +6,7 @@ rescue LoadError => e
end
require 'digest/md5'
+require 'active_support/core_ext/marshal'
module ActiveSupport
module Cache
diff --git a/activesupport/lib/active_support/core_ext/marshal.rb b/activesupport/lib/active_support/core_ext/marshal.rb
new file mode 100644
index 0000000000..fec3051c0c
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/marshal.rb
@@ -0,0 +1,21 @@
+module Marshal
+ class << self
+ def load_with_autoloading(source)
+ begin
+ load_without_autoloading(source)
+ rescue ArgumentError, NameError => exc
+ if exc.message.match(%r|undefined class/module (.+)|)
+ # try loading the class/module
+ $1.constantize
+ # if it is a IO we need to go back to read the object
+ source.rewind if source.respond_to?(:rewind)
+ retry
+ else
+ raise exc
+ end
+ end
+ end
+
+ alias_method_chain :load, :autoloading
+ end
+end \ No newline at end of file