On Sat, 7 Jul 2001, Jim Freeze wrote: > On Sat, 7 Jul 2001, Avi Bryant wrote: > > > Here's a somewhat cheesy solution: > > > > class Package > > def clone > > Marshal.load(Marshal.dump self) > > end > > end > > > If it is Parmesean cheese, then it is OK. :) > What you suggest fixes the problem of manually > specifying all the classes that Package may > contain. What still remains is to put this > burdon upon Box and not Package. I don't think that's possible - what you're asking is for Box to affect how Package makes copies of itself. Since, in a default dup, it's only the pointer to the contained Box that gets copied, no method of Box ever gets called, and so it never has a chance to intervene. What I would suggest instead is simply to do something like module DeepCopy def clone Marshal.load(Marshal.dump self) end end and then include that module in Package and all similar classes.