line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mongol::Models::Page; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
8
|
use Moose; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
10
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'Mongol::Model'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'items' => ( |
8
|
|
|
|
|
|
|
is => 'ro', |
9
|
|
|
|
|
|
|
isa => 'ArrayRef[Mongol::Model]', |
10
|
|
|
|
|
|
|
default => sub { [] }, |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'total' => ( |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
isa => 'Int', |
16
|
|
|
|
|
|
|
default => 0, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has 'start' => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
isa => 'Int', |
22
|
|
|
|
|
|
|
default => 0, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has 'rows' => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
isa => 'Int', |
28
|
|
|
|
|
|
|
default => 0, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__PACKAGE__->meta()->make_immutable(); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=pod |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Mongol::Models::Page - Result object for pagination |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 SYNOPSIS |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
use POSIX qw( ceil ); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $page = Models::Person->paginate( { age => { '$gt' => 25 } }, 0, 10 ); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $total_pages = ceil( $page->total() / $page->rows() ); |
50
|
|
|
|
|
|
|
my $current_page = ( $page->start() / $page->rows() ) + 1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DESCRIPTION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 items |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $array_ref = $page->items(); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 start |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $start = $page->start(); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 rows |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my $rows = $page->rows(); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SEE ALSO |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=over 4 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item * |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
L<Mongol::Model> |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=back |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |