[前][次][番号順一覧][スレッド一覧]

ruby-changes:14335

From: marcandre <ko1@a...>
Date: Thu, 24 Dec 2009 13:09:17 +0900 (JST)
Subject: [ruby-changes:14335] Ruby:r26164 (ruby_1_8): * lib/delegate.rb (marshal_dump/load): dump & load instance variables by default

marcandre	2009-12-24 13:09:07 +0900 (Thu, 24 Dec 2009)

  New Revision: 26164

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26164

  Log:
    * lib/delegate.rb (marshal_dump/load): dump & load instance variables by default [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 26163)
+++ ruby_1_8/lib/delegate.rb	(revision 26164)
@@ -178,10 +178,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])}
     initialize_methods(obj)
     __setobj__(obj)
   end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]