[Catalyst-commits] r7288 -
trunk/examples/CatalystAdvent/root/2007/pen
zby at dev.catalyst.perl.org
zby at dev.catalyst.perl.org
Wed Dec 12 20:30:17 GMT 2007
Author: zby
Date: 2007-12-12 20:30:17 +0000 (Wed, 12 Dec 2007)
New Revision: 7288
Modified:
trunk/examples/CatalystAdvent/root/2007/pen/15.pod
Log:
some simplifications form Jonas
Modified: trunk/examples/CatalystAdvent/root/2007/pen/15.pod
===================================================================
--- trunk/examples/CatalystAdvent/root/2007/pen/15.pod 2007-12-12 18:13:34 UTC (rev 7287)
+++ trunk/examples/CatalystAdvent/root/2007/pen/15.pod 2007-12-12 20:30:17 UTC (rev 7288)
@@ -45,23 +45,20 @@
use warnings;
use base qw( DBIx::Class::ResultSet );
-
+
sub advanced_search {
my ( $self, $params, $attrs ) = @_;
+ my $columns = {};
for my $column ( keys %$params ){
- if( my $search = $self->can( 'search_for_' . $column ) ){
+ if( my $search = $self->can( "search_for_$column" ) ){
$self = $self->$search( $params );
next;
}
- my ( $full_name, $relation ) = simple_predicate( $column );
- my $join;
- $join = { join => [ $relation ] } if $relation;
- $self = $self->search(
- { $full_name => $params->{$column} },
- $join,
- );
+ my ( $full_name, $relation ) = $self->simple_predicate( $column );
+ $self = $self->search({}, { join => $relation });
+ $columns->{$full_name} = $params->{$column};
}
- $self = $self->search( {}, $attrs );
+ $self = $self->search( $columns, $attrs );
return (wantarray ? $self->all : $self)
}
@@ -89,7 +86,7 @@
records. For that we have the simple_predicate function. It looks like that:
sub simple_predicate {
- my $field = shift;
+ my ( $self, $field) = @_;
if( $field =~ /(.*?)\.(.*)/ ){
my $first = $1;
my $rest = $2;
More information about the Catalyst-commits
mailing list