Take a look at how I overloaded "new" in DateTime::Fiscal::Retail454. I had the same problem you describe.
Jim > -----Original Message----- > From: Boorstein, Daniel B [mailto:[EMAIL PROTECTED] > Sent: Tuesday, March 27, 2007 9:43 AM > To: [email protected] > Subject: instance data for DateTime derived classes > > > Hello All, > > I have a package called Qf::DateTime that does a "use base 'DateTime'". > From here I've added convenience methods and overridden a few of the > core DateTime methods to my liking. > > In doing this I was a bad OO programmer and broke encapsulation. In > Qf::DateTime objects I hung various member variables off of $self, such > as $self->{'_qf_holidays'} to support my custom methods. > > This has worked very well for several years now. Unfortunately, due to > the recent necessity to upgrade DateTime and DateTime::TimeZone, the > custom data attached to the object gets stripped after calling > $dt->add() for example. At a glance, it appears this happens at the end > of add_duration() when from_object() is called. > > I realize this is my problem since I broke encapsulation, but I'm > wondering if others have dealt with this already. Is there a designated > means for derived classes to add custom instance data? I've perused the > docs, but didn't see anything specific for authors of derived classes. > > Thanks, > > - Dan Boorstein >
