ruby-changes:14334
From: marcandre <ko1@a...>
Date: Thu, 24 Dec 2009 12:08:38 +0900 (JST)
Subject: [ruby-changes:14334] Ruby:r26163 (trunk): * lib/delegate.rb (marshal_dump/load): dump & load instance variables by default
marcandre 2009-12-24 12:08:15 +0900 (Thu, 24 Dec 2009) New Revision: 26163 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26163 Log: * lib/delegate.rb (marshal_dump/load): dump & load instance variables by default [ruby-core:24211] Modified files: trunk/ChangeLog trunk/lib/delegate.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 26162) +++ ChangeLog (revision 26163) @@ -1,3 +1,8 @@ +Thu Dec 24 12:08:00 2009 Marc-Andre Lafortune <ruby-core@m...> + + * lib/delegate.rb (marshal_dump/load): dump & load instance variables + by default [ruby-core:24211] + Thu Dec 24 10:31:50 2009 Marc-Andre Lafortune <ruby-core@m...> * lib/object.c (rb_obj_cmp): Default <=> operator returns 0 if Index: lib/delegate.rb =================================================================== --- lib/delegate.rb (revision 26162) +++ lib/delegate.rb (revision 26163) @@ -183,10 +183,16 @@ # Serialization support for the object returned by \_\_getobj\_\_. def marshal_dump - __getobj__ + [ + 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) end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/