diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-03 09:58:19 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-03 09:58:19 +0000 |
| commit | 672e141ad23cd9593592aa3220620b17ea12c326 (patch) | |
| tree | 128dcb6a9757cfaabddd9e3f5a35ab71087b636b /lib | |
| parent | 0eeeb2ef4c3183e094a9b4b546bee28068d5113d (diff) | |
| download | ruby-672e141ad23cd9593592aa3220620b17ea12c326.tar.gz ruby-672e141ad23cd9593592aa3220620b17ea12c326.tar.xz ruby-672e141ad23cd9593592aa3220620b17ea12c326.zip | |
* lib/ostruct.rb: 1.9 marshaling support back-ported.
[ruby-core:03871]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@7448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ostruct.rb | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/ostruct.rb b/lib/ostruct.rb index 7f4668283..b30ae640c 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -59,21 +59,17 @@ class OpenStruct @table = @table.dup end - module Marshaler - def marshal_dump - table = @table - OpenStruct.new.instance_eval{@table=table; self} - end - def marshal_load(x) - @table = x.instance_variable_get("@table") - @table.each_key{|key| new_ostruct_member(key)} - end + def marshal_dump + @table + end + def marshal_load(x) + @table = x + @table.each_key{|key| new_ostruct_member(key)} end def new_ostruct_member(name) unless self.respond_to?(name) self.instance_eval %{ - extend OpenStruct::Marshaler def #{name}; @table[:#{name}]; end def #{name}=(x); @table[:#{name}] = x; end } |
