From: Brian Candler Date: 2009-10-27T23:56:01+09:00 Subject: Re: UnMarshal without source file Manny Calavera wrote: > My idea was: ... > But something more STANDARD Well, a Class itself is not marshalable, nor is the singleton class of an object. If you want to save and restore the *definitions* of classes automatically, you'll have to do something very funky using ParseTree or the like. Otherwise, I'd say your approach might be reasonable, but is rather dangerous and duplicates definitions of methods. How about this? module MyMarshal def dump(obj) Marshal.dump [$LOADED_FEATURES, Marshal.dump(obj)] end module_function :dump def load(str) requires, dump = Marshal.load(str) requires.each do |r| require r.sub(/\.rb\z/,'') end Marshal.load(dump) end module_function :load end This depends on your class definitions being available in source files which are loaded using 'require'. It has obvious downsides, but something like this might work for you. It really depends on what your application is trying to do. Why are you loading objects which are not defined in the context of the loading application? How would you know what methods to call on those objects? Regards, Brian. -- Posted via http://www.ruby-forum.com/.