Daniel Westermann-Clark wrote:
> On 2006-09-25 10:47:05 -0700, Roderick A. Anderson wrote:
> 
>>But if the case is the record already exists ( find_ ) I don't need a 
>>call to rebuild a list but if it doesn't exist ( _create ) I need to 
>>make the call.
>>
>>The POD says it returns the $obj.  Is there elegant way to determine
>>if it is a found or created object?  If not, does it make sense to
>>have the something_or_otherthing methods also return which of the
>>two happened?
> 
> 
> Sounds like you want find_or_new, followed by an in_storage check:
> 
> my $obj = $rs->find_or_new({ blah => 'blarg' });
> unless ($obj->in_storage) {
>     $obj->insert;
>     # rebuild list
>     # yay!
> }

Wow!!!

I just re-read the POD and there it was and the most embarrassing part 
is I actually read it thought about it but it didn't click.


Thanks.
Rod
-- 
> 


_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to