line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Skinny::Pager; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
45
|
use strict; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
233
|
|
4
|
7
|
|
|
7
|
|
36
|
use warnings; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
198
|
|
5
|
7
|
|
|
7
|
|
37
|
use base 'DBIx::Skinny::SQL'; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
7573
|
|
6
|
7
|
|
|
7
|
|
46149
|
use DBIx::Skinny::Pager::Page::Default; |
|
7
|
|
|
|
|
30
|
|
|
7
|
|
|
|
|
98
|
|
7
|
7
|
|
|
7
|
|
4387
|
use DBIx::Skinny::Pager::ResultSet; |
|
7
|
|
|
|
|
20
|
|
|
7
|
|
|
|
|
166
|
|
8
|
7
|
|
|
7
|
|
73
|
use Class::Accessor::Lite; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
56
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Class::Accessor::Lite->mk_accessors(qw/page/); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub get_total_entries { |
15
|
0
|
|
|
0
|
0
|
0
|
die "please override"; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub pager_class { |
19
|
3
|
|
|
3
|
0
|
11
|
"DBIx::Skinny::Pager::Page::Default"; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub retrieve { |
23
|
6
|
|
|
6
|
0
|
14151
|
my $self = shift; |
24
|
6
|
50
|
|
|
|
19
|
Carp::croak("limit not found") unless defined($self->limit); |
25
|
6
|
100
|
|
|
|
45
|
unless ( defined($self->offset) ) { |
26
|
2
|
50
|
|
|
|
17
|
Carp::croak("limit or page not found") unless defined($self->page); |
27
|
2
|
|
50
|
|
|
19
|
$self->offset($self->limit * ( (int($self->page) || 1) - 1) ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
6
|
|
|
|
|
75
|
my $iter = $self->SUPER::retrieve(@_); |
31
|
6
|
|
|
|
|
207
|
my $total_entries = $self->get_total_entries($iter); |
32
|
6
|
|
|
|
|
135
|
my $pager = $self->pager_class->new($total_entries, $self->limit, ( $self->offset / $self->limit) + 1); |
33
|
|
|
|
|
|
|
|
34
|
6
|
100
|
|
|
|
489
|
if ( wantarray ) { |
35
|
4
|
|
|
|
|
14
|
return ( $iter, $pager ); |
36
|
|
|
|
|
|
|
} else { |
37
|
2
|
|
|
|
|
20
|
return DBIx::Skinny::Pager::ResultSet->new( |
38
|
|
|
|
|
|
|
iterator => $iter, |
39
|
|
|
|
|
|
|
pager => $pager, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
__END__ |