line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::DBI::Pager; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
29373
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
51
|
|
4
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION $AUTOLOAD); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
72
|
|
5
|
|
|
|
|
|
|
$VERSION = 0.08; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
1508
|
use Class::DBI 0.90; |
|
1
|
|
|
|
|
138026
|
|
|
1
|
|
|
|
|
13
|
|
8
|
1
|
|
|
1
|
|
1157
|
use Data::Page; |
|
1
|
|
|
|
|
3729
|
|
|
1
|
|
|
|
|
11
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub import { |
11
|
1
|
|
|
1
|
|
14
|
my $class = shift; |
12
|
1
|
|
|
|
|
2
|
my $pkg = caller(0); |
13
|
1
|
|
|
1
|
|
63
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
185
|
|
14
|
1
|
|
|
|
|
3
|
*{"$pkg\::pager"} = \&_pager; |
|
1
|
|
|
|
|
130
|
|
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
|
|
sub _croak { require Carp; Carp::croak(@_); } |
|
0
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _pager { |
20
|
0
|
|
|
0
|
|
|
my($pkg, $entry, $curr) = @_; |
21
|
0
|
|
|
|
|
|
bless { |
22
|
|
|
|
|
|
|
pkg => $pkg, |
23
|
|
|
|
|
|
|
entry => $entry, |
24
|
|
|
|
|
|
|
curr => $curr, |
25
|
|
|
|
|
|
|
pager => undef, |
26
|
|
|
|
|
|
|
}, __PACKAGE__; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
BEGIN { |
30
|
1
|
|
|
1
|
|
4
|
my @methods = qw(total_entries entries_per_page current_page entries_on_this_page |
31
|
|
|
|
|
|
|
first_page last_page first last previous_page next_page pages_in_navigation); |
32
|
1
|
|
|
|
|
3
|
for my $method (@methods) { |
33
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
84
|
|
34
|
|
|
|
|
|
|
*$method = sub { |
35
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
36
|
0
|
0
|
|
|
|
0
|
$self->{pager} or _croak("Can't call pager methods without searching"); |
37
|
0
|
|
|
|
|
0
|
$self->{pager}->$method(@_); |
38
|
11
|
|
|
|
|
380
|
}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
0
|
|
|
sub DESTROY { } |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub AUTOLOAD { |
45
|
0
|
|
|
0
|
|
|
my $self = shift; |
46
|
0
|
|
|
|
|
|
(my $method = $AUTOLOAD) =~ s/.*://; |
47
|
0
|
0
|
0
|
|
|
|
if (ref($self) && $self->{pkg}->can($method)) { |
48
|
0
|
|
|
|
|
|
my $iter = $self->{pkg}->$method(@_); |
49
|
0
|
0
|
|
|
|
|
UNIVERSAL::isa($iter, 'Class::DBI::Iterator') |
50
|
|
|
|
|
|
|
or _croak("$method doesn't return Class::DBI::Itertor"); |
51
|
0
|
|
|
|
|
|
my $pager = $self->{pager} = Data::Page->new( |
52
|
|
|
|
|
|
|
$iter->count, $self->{entry}, $self->{curr}, |
53
|
|
|
|
|
|
|
); |
54
|
0
|
|
|
|
|
|
return $iter->slice($pager->first-1, $pager->last-1); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
else { |
57
|
0
|
|
0
|
|
|
|
_croak(qq(Can't locate object method "$method" via package ) . ref($self) || $self); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
__END__ |