[Templates] [PATCH] allow forcing scalar context to deal with ornery object methods

Ash Berlin ash_cpan at firemirror.com
Tue Jan 22 17:40:04 GMT 2008


On Jan 22, 2008, at 5:31 PM, mike wrote:

> On Jan 22, 2008 3:38 AM, Ash Berlin <ash_cpan at firemirror.com> wrote:
>> Yes wantarray is annoying. But oh look, its almost as if  
>> DBIx::Class users
>> use TT to. I point you at search_rs:
>
> i already know about search_rs.
>
>> From DBIx::Class::Relationship:
>>
>> Three methods are created when you create a has_many relationship.   
>> The
>> first method is the expected accessor method, C<$accessor_name()>.   
>> The
>> second is almost exactly the same as the accessor method but "_rs" is
>> added to the end of the method name.
>
> i did not, however, know about this.
>
>> These features have been in DBIx::Class since about mid-2006.
>>
>> [% category.products_rs.search_related_rs('authorizations').
>> magazine_rs.trade_rs.collecting_rs.count %]
>>
>> Should do the same job.
>
> no, it won't, because there is not a search_related_rs method.

No really, there is: http://search.cpan.org/~ash/DBIx-Class-0.08008/lib/DBIx/Class/Relationship/Base.pm#search_related_rs

(BTW that wasn't to say that your SCALAR patch isn't useful, jsut that  
there are otherways to achieve this in DBIC. Patch is a good idea in  
my view)



More information about the templates mailing list