From: Brian Candler Date: 2009-12-10T00:21:26+09:00 Subject: Re: DRB class in array Sausheong Chang wrote: > I have a slightly different problem. I have an array stored in the > object: > > class Room > include DRb::DRbUndumped > attr_accessor :name > attr_accessor :game > attr_accessor :observers > > def initialize(name=nil) > @game = nil > @observers = [] > @name = name > end > end > > And the object is stored at the 'server'. At the 'client' I got the > object and is able to modify the @name instance variable at the > 'server'. However when I tried to add objects to the @observers array it > doesn't seem to appear at the 'server'. What could be wrong? Try this: @observers = [].extend DRb::DRbUndumped I think the same thing is happening one level down: although the Room instance stays where it is, when you make a call across the net to room.observers the return value is a *copy* of this array. Another solution is to remove the attr_accessor for observers completely, and instead implement separate methods for what the client really needs to do - e.g. add an observer, remove an observer, iterate across observers. -- Posted via http://www.ruby-forum.com/.