Re: different versions of objects
[prev]
[thread]
[next]
[Date index for 2005/04/06]
On Wed, 2005-04-06 at 17:31 +0100, Simon Wistow wrote:
> I have various objects and all these objects have versions. What I want
> to be able to do is
>
> $package = Package->new($name); # latest version
> $package = Package->new($name, $version); # gets $version
>
> $package->version(); # returns $version
> $package->version($new_version); # changes to $new_version
>
> I suspect what the best thing to do is make Package have an id and a
> name and has_many Package::Version. Package.pm will then have an
> AUTOLOAD which forwards any method calls not covered in Package.pm
> (name, version) to $self->{_current_version}->$method or something
> similar.
>
> Does that sound sane?
Not really. I consider AUTOLOAD a last resort. What you're showing
here could be done pretty simply by adding a couple of methods to a
standard Class::DBI class. The final bit (replacing the current object
with a different one) is tricky, so I might change that.
- Perrin
 |
 |
Re: different versions of objects
Perrin Harkins 18:45 on 06 Apr 2005
|