diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-24 03:08:15 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-24 03:08:15 +0000 |
commit | 30793b7ca6cccaaac5d87a0f4c4cc152db841ff9 (patch) | |
tree | d7b634b179b6a8e0303b8722bdac59ced525c573 | |
parent | f07fdd7661ffcee20816a20e152074d6f1a2594a (diff) | |
download | ruby-30793b7ca6cccaaac5d87a0f4c4cc152db841ff9.tar.gz ruby-30793b7ca6cccaaac5d87a0f4c4cc152db841ff9.tar.xz ruby-30793b7ca6cccaaac5d87a0f4c4cc152db841ff9.zip |
* lib/delegate.rb (marshal_dump/load): dump & load instance variables by default [ruby-core:24211]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@26163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/delegate.rb | 8 |
2 files changed, 12 insertions, 1 deletions
@@ -1,3 +1,8 @@ +Thu Dec 24 12:08:00 2009 Marc-Andre Lafortune <[email protected]> + + * 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 <[email protected]> * lib/object.c (rb_obj_cmp): Default <=> operator returns 0 if diff --git a/lib/delegate.rb b/lib/delegate.rb index 77804e47f..f8a71f186 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -183,10 +183,16 @@ class Delegator # 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 |