From: Javier S. <jav...@ri...> - 2007-10-26 09:02:00
|
Eloy, The problem is that when the hash or array holds values that have been mutated into cocoa variants, the marshal will fail, so I have to deeply transverse the data structure making sure each and every number, string array and hash held inside is in fact a ruby object just before issuing the marshal dump message. Moreover, I can't just use #to_ruby because ruby objects don't understand that message, so I end up using to_i, to_f, to_array, .. on each object in the data structure to replace it with ruby objects when I know beforehand what type to expect and #class in a switch statement when I don't to decide what type to transform it into. Jeez, looks more like java and type coercing and less like Ruby. Perhaps I should extend cocoa objects with marshal messages that save and load ruby classes? JS Hi Javier, This is intended behaviour. Ruby arrays and hashes etc do not have what it takes to be able to use with bindings etc. Don't worry about it to much, you can ducktype most of the stuff. You can always use #to_hash or #to_a: Marshal.dump(ns_dict.to_hash) Or if you are ducktyping you can use #to_ruby which resolves the ruby variants of the objects that you have: Marshal.dump(obj.to_ruby) Cheers, Eloy |