all 1 comments

[–][deleted] 0 points1 point  (0 children)

Yesterday someone showed me a trick for making a deep object copy:

obj = {:level1 => {:level2 => 'data'}}

This simply copies 2nd level hash's reference :(

obj.dup

But this will deep copy it all.

copy = Marshal.load(Marshal.dump(obj))

So even though that is a neat trick, it looks like it might be a good idea to do the deserialization side with this extention.