ruby-changes:14364
From: marcandre <ko1@a...>
Date: Tue, 29 Dec 2009 10:58:53 +0900 (JST)
Subject: [ruby-changes:14364] Ruby:r26194 (ruby_1_8): * lib/delegate.rb (marshal_dump/load): Provide forward compatibility
marcandre 2009-12-29 10:56:55 +0900 (Tue, 29 Dec 2009) New Revision: 26194 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26194 Log: * lib/delegate.rb (marshal_dump/load): Provide forward compatibility [ruby-core:24211] Modified files: branches/ruby_1_8/lib/delegate.rb Index: ruby_1_8/lib/delegate.rb =================================================================== --- ruby_1_8/lib/delegate.rb (revision 26193) +++ ruby_1_8/lib/delegate.rb (revision 26194) @@ -179,17 +179,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])} - initialize_methods(obj) - __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 end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/