# Author:: Nicolas Despres . # Copyright:: Copyright (c) 2004 TTK Team. All rights reserved. # License:: Ruby license. # $LastChangedBy: polrop $ # $Id: drb_undumped_indexed_object.rb 73 2004-12-09 18:24:52Z polrop $ require 'drb' module DRb module DRbUndumpedIndexedObject def DRbUndumpedIndexedObject.append_features(cl) super cl.module_eval do def _dump(depth) if self.class.include?(DRb::DRbUndumped) raise(TypeError, 'can\'t dump') end attribs = {} each_pair do |k, v| begin attribs[k] = Marshal.dump(v) rescue TypeError if (defined? LOG) and (not v.class.include? DRb::DRbUndumped) LOG.warn("#{self.class}._dump") do "can't dump a #{k}:#{v.class}" end end attribs[k] = Marshal.dump(DRbObject.new(v)) end end Marshal.dump([self.class, attribs]) end def self._load(data) klass, attribs = Marshal.load(data) obj = klass.new attribs.each do |key, value| obj[key] = Marshal.load(value) end obj end end end end # module DRbUndumpedIndexedObject end # module DRb