On Jan 30, 2007, at 12:55, John Siracusa wrote: I like it!
We have all sorts of utility methods in our model classes to fetch child objects where just calling ->children wasn't exact enough. On a vaguely related note, in our manager class we have the following three methods. In particular the first one is incredibly helpful (although I sometimes get tripped up by forgetting by how ->new->load needs unique keys). sub fetch { my $self = shift; my $obj = $self->object_class->new(@_); $obj->load(speculative => 1) ? $obj : undef; } sub fetch_or_create { my $self = shift; my $obj = $self->object_class->new(@_); $obj->load(speculative => 1); $obj; } sub create { shift->object_class->new(@_); } > # Same as above (hashref as first arg is taken as query) > @low_prices = $p->find_prices({ price => { lt => 10 } }); This should make it easily call-able from Template Toolkit, too (for better or worse). - ask -- http://develooper.com/ - http://askask.com/ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object