[CDBI] Best way to do this

Kate Yoak kate at yoak.com
Sat Sep 10 04:27:19 BST 2005


I am attempting to do something that ought to be easy, but I can't quite
figure out the best approach.

BOB->has_many('friends'...);

But I'd like to put a little custom logic into BOB->friend, such as:

sub friends{
 my $self = shift;
 my $friends = $self->SUPER::friends(@_);
 if (@friends ==1 && !wantarray){
	return shift @friends;
 }
 ...
}

Of course HasMany complains about already having friends defined.  I can
certainly work around this, and I might anyway - but what's a good way to
solve the general case of doing some post-processing on the data?






More information about the ClassDBI mailing list