ruby-changes:14365
From: marcandre <ko1@a...>
Date: Tue, 29 Dec 2009 10:59:14 +0900 (JST)
Subject: [ruby-changes:14365] Ruby:r26195 (trunk): * lib/delegate.rb (marshal_dump/load): Provide forward compatibility
marcandre 2009-12-29 10:56:55 +0900 (Tue, 29 Dec 2009) New Revision: 26195 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26195 Log: * lib/delegate.rb (marshal_dump/load): Provide forward compatibility [ruby-core:24211] Modified files: trunk/lib/delegate.rb Index: lib/delegate.rb =================================================================== --- lib/delegate.rb (revision 26194) +++ lib/delegate.rb (revision 26195) @@ -184,16 +184,21 @@ # 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\_\_. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/