1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/ostruct.rb: 1.9 marshaling support back-ported.

[ruby-core:03871]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2004-12-03 09:58:19 +00:00
parent 379e85a5f5
commit 4de33a3ac4
2 changed files with 11 additions and 10 deletions

View file

@ -1,3 +1,8 @@
Fri Dec 3 18:57:03 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/ostruct.rb: 1.9 marshaling support back-ported.
[ruby-core:03871]
Fri Dec 3 13:45:20 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (proc_invoke): copy arguments to frame.argv.

View file

@ -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
}