@params{'page', 'pages'} = ($page, $pages);
$rs = $rs->search(undef, {offset => ($page - 1) * PAGE_SIZE, ($page == $pages ? () : (rows => PAGE_SIZE))});
}
- $rs = $rs->search(undef, {prefetch => $thing{prefetch}}) if exists $thing{prefetch};
+ $rs = $rs->search(undef, {
+ exists $thing{prefetch} ? (prefetch => $thing{prefetch}) : (),
+ exists $thing{columns} ? (columns => $thing{columns}) : (),
+ });
my @thing = map +{rs => $_, $_->get_columns}, $rs->all;
@thing = map { $thing{mangle}->(); $_ } @thing if exists $thing{mangle};
@thing = grep { $thing{choose}->() } @thing if exists $thing{choose};
my ($thing, $lang, $env, $id) = @_;
my %thing = %$thing;
debug $env => "Rsname is $thing{rsname} and id is $id";
- $thing{makers} //= sub { db(shift)->resultset($thing{rsname}) };
- my %params = map {+ rs => $_, $_->get_columns } $thing{makers}->($env)->find($id);
+ my %params = map {+ rs => $_, $_->get_columns } db($env)->resultset($thing{rsname})->find($id);
$thing{mangle}->(local $_ = \%params) if exists $thing{mangle};
wantarray ? %params : \%params
}
sub group (&);
sub mangle (&);
sub prefetch;
+sub columns;
sub thing (&){
my %thing;
local *{"group"} = sub { $thing{group} = shift };
local *{"makers"} = sub { $thing{makers} = shift };
local *{"prefetch"} = sub { $thing{prefetch} = \@_ };
+ local *{"columns"} = sub { $thing{columns} = \@_ };
use strict 'refs';
shift->();