blib/lib/Sledge/Plugin/Paginate.pm

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 CC 1 SCAR 0.9
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
↑ Summary
1 package Sledge::Plugin::Paginate;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 our $VERSION = '0.01';
7  
8 0 ▶use Data::Page;
Subroutine BEGIN: called CC=1 SCAR=2.6
9 our $REQUEST_PARAM = 'page';
10  
11 sub import {
12 my $self = shift;
13 my $pkg = caller;
14  
15 no strict 'refs';
16 *{"$pkg\::paginate"} = sub {
17 my ($self , %args) = @_;
18  
19 my $pager = Data::Page->new(
20 scalar(@{$args{data}}),
21 $args{paging_num},
22 $self->r->param($REQUEST_PARAM) || 0,
23 );
24  
25 $self->tmpl->param(
26 $args{page_name} => [ $pager->splice($args{data}) ],
27 pager => $pager,
28 );
29 };
30 }
31  
32  
33 =head1 NAME
34  
35 Sledge::Plugin::Paginate - data paginate plugin for Sledge
36  
37 =head1 VERSION
38  
39 This documentation refers to Sledge::Plugin::Paginate version 0.01
40  
41 =head1 SYNOPSIS
42  
43 package Your::Pages;
44 use Sledge::Plugin::Paginate;
45  
46 sub dispatch_index {
47 my $self = shift;
48  
49 my @users = $self->user;
50  
51 $self->paginate(
52 paging_num => $self->config->paging_num,
53 page_name => 'user',
54 data => \@users,
55 );
56 }
57  
58 =head1 METHODS
59  
60 =head2 paginate
61  
62 This paginate plugin can easily execute paging.
63  
64 =head1 AUTHOR
65  
66 Atsushi Kobayashi, C<< <nekokak at gmail.com> >>
67  
68 =head1 BUGS
69  
70 Please report any bugs or feature requests to
71 C<bug-sledge-plugin-paginate at rt.cpan.org>, or through the web interface at
72 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sledge-Plugin-Paginate>.
73 I will be notified, and then you'll automatically be notified of progress on
74 your bug as I make changes.
75  
76 =head1 SUPPORT
77  
78 You can find documentation for this module with the perldoc command.
79  
80 perldoc Sledge::Plugin::Paginate
81  
82 You can also look for information at:
83  
84 =over 4
85  
86 =item * AnnoCPAN: Annotated CPAN documentation
87  
88 L<http://annocpan.org/dist/Sledge-Plugin-Paginate>
89  
90 =item * CPAN Ratings
91  
92 L<http://cpanratings.perl.org/d/Sledge-Plugin-Paginate>
93  
94 =item * RT: CPAN's request tracker
95  
96 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Sledge-Plugin-Paginate>
97  
98 =item * Search CPAN
99  
100 L<http://search.cpan.org/dist/Sledge-Plugin-Paginate>
101  
102 =back
103  
104 =head1 ACKNOWLEDGEMENTS
105  
106 =head1 COPYRIGHT & LICENSE
107  
108 Copyright 2006 Atsushi Kobayashi, all rights reserved.
109  
110 This program is free software; you can redistribute it and/or modify it
111 under the same terms as Perl itself.
112  
113 =cut
114  
115 1; # End of Sledge::Plugin::Paginate
↑ Summary