From: Ronald Pijnacker Date: 2003-07-08T18:16:01+09:00 Subject: Re: Marshaling objects partially > > Hi, > > > > In message "Marshaling objects partially" > > on 03/07/07, Ronald Pijnacker writes: > > > > |I had a look at _dump and _load, but it seems to me that I'd have to > > |solve the cyclic references myself again. Is this true? > > > > Yes. > > > > But if you use Marshal.dump for _dump, Marshal resolves cycles > > (potential duplication might happen). > > Thanks, this works fine. > > Do you have any suggestions on how to orgainize _load and _dump such > that in a class hierarchy every class level is responsible for streaming > its own members? On second tought... it does not seem to work fine for cycles. The following example breaks down with a SystemStackError: class Foo attr_accessor :bar def _dump(limit) Marshal.dump([@bar], limit-1) end def Foo._load(str) data = Marshal.load(str) obj = self.new obj.bar = data.shift end end foo1 = Foo.new foo2 = Foo.new foo1.bar = foo2 foo2.bar = foo1 str = Marshal.dump(foo1) It works ok without the _dump/_load part. Ronald.