summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-12-29 01:56:55 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-12-29 01:56:55 +0000
commitc227eef16e652dbfc0ceae27c30901f57814ea46 (patch)
treeaaadefbaee966b8fc1132f950cab370391be9f51
parentb62936e1904a448ba12fdcf54e33ccc1501df885 (diff)
downloadruby-c227eef16e652dbfc0ceae27c30901f57814ea46.tar.gz
ruby-c227eef16e652dbfc0ceae27c30901f57814ea46.tar.xz
ruby-c227eef16e652dbfc0ceae27c30901f57814ea46.zip
* lib/delegate.rb (marshal_dump/load): Provide forward compatibility [ruby-core:24211]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@26195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/delegate.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/delegate.rb b/lib/delegate.rb
index f8a71f186..1516dacb1 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -184,16 +184,21 @@ class Delegator
# Serialization support for the object returned by \_\_getobj\_\_.
def marshal_dump
[
+ :__v2__,
instance_variables,
instance_variables.map{|var| instance_variable_get(var)},
__getobj__
]
end
# Reinitializes delegation from a serialized object.
- def marshal_load(obj)
- vars, values, obj = obj
- vars.each_with_index{|var, i| instance_variable_set(var, values[i])}
- __setobj__(obj)
+ def marshal_load(data)
+ version, vars, values, obj = data
+ if version == :__v2__
+ vars.each_with_index{|var, i| instance_variable_set(var, values[i])}
+ __setobj__(obj)
+ else
+ __setobj__(data)
+ end
end
# Clone support for the object returned by \_\_getobj\_\_.