blib/lib/Teng/Plugin/SearchBySQLAbstractMore/Pager.pm

filter: Statementstmt 100% 38 / 38 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 50.0% 1 / 2 totaltotal 96.3% 53 / 55 CC 4 SCAR 6.9
CC
4
Cov
98%
search_by_sql_abstract_more_with_pager
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« blib/lib/Teng/Plugin/SearchBySQLAbstractMore/Pager/MySQLFoundRows.pm ↑ Summary _build/lib/MyBuilder.pm »
1 package Teng::Plugin::SearchBySQLAbstractMore::Pager;
2  
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 10 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 10 ▶use Teng::Iterator;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use Data::Page::NoTotalEntries;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use Teng::Plugin::SearchBySQLAbstractMore ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 10 our @EXPORT = qw/search_by_sql_abstract_more_with_pager/;
12  
13 sub init {
14 10 ▶ $_[1]->Teng::Plugin::SearchBySQLAbstractMore::_init();
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
15 }
16  
17 # work around
18 10 push @EXPORT, qw/sql_abstract_more_instance/;
19 10 *sql_abstract_more_instance = \&Teng::Plugin::SearchBySQLAbstractMore::sql_abstract_more_instance;
20  
21 sub search_by_sql_abstract_more_with_pager {
22 6 ▶ my ($self, $table_name, $where, $_opt) = @_;
Subroutine search_by_sql_abstract_more_with_pager: called CC=4 SCAR=13.9
Pod documented
23 6 ($table_name, my($args, $rows, $page)) = Teng::Plugin::SearchBySQLAbstractMore::_arrange_args($table_name, $where, $_opt);
24  
25 6 ▶ my $table = $self->schema->get_table($table_name) or Carp::croak("No such table $table_name");
Branch: 1 branch
BranchTrueFalseTotal
my $table = $self->schema->get_table($table_name) or Carp::croak("No such table $table_name") 0 6 6
26 6 $args->{-limit} += 1;
27 6 my ($sql, @binds) = $self->sql_abstract_more_instance->select(%$args);
28  
29 6 my $sth = $self->execute($sql, \@binds);
30 6 my $ret = [ Teng::Iterator->new(
31 teng => $self,
32 sth => $sth,
33 sql => $sql,
34 row_class => $self->schema->get_row_class($table_name),
35 table_name => $table_name,
36 suppress_object_creation => $self->suppress_row_objects,
37 )->all];
38  
39 6 ▶ my $has_next = ( $rows + 1 == scalar(@$ret) ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$rows + 1 == scalar @$ret ? : 3 3 6
40 6 ▶ if ($has_next) {
Branch: 1 branch
BranchTrueFalseTotal
if ($has_next) 3 3 6
41 3 pop @$ret;
42 }
43  
44 6 my $pager = Data::Page::NoTotalEntries->new
45 (
46 entries_per_page => $rows,
47 current_page => $page,
48 has_next => $has_next,
49 entries_on_this_page => scalar(@$ret),
50 );
51 6 return ($ret, $pager);
52 }
53  
54 =pod
55  
56 =head1 NAME
57  
58 Teng::Plugin::SearchBySQLAbstractMore::Pager - pager plugin using SQL::AbstractMore as Query Builder for Teng
59  
60 =head1 SYNOPSIS
61  
62 see Teng::Plugin::SearchBySQLAbstractMore
63  
64 =head1 METHODS
65  
66 =head2 search_by_sql_abstract_more_with_pager
67  
68 C<search_by_sql_abstract_more> with paging feature.
69 additional parameter can be taken, C<page> and C<rows>.
70  
71 =head1 AUTHOR
72  
73 Ktat, C<< <ktat at cpan.org> >>
74  
75 =head1 BUGS
76  
77 Please report any bugs or feature requests to C<bug-teng-plugin-searchbysqlabstractmore at rt.cpan.org>, or through
78 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Teng-Plugin-SearchBySQLAbstractMore>. I will be notified, and then you'll
79 automatically be notified of progress on your bug as I make changes.
80  
81 =head1 SUPPORT
82  
83 You can find documentation for this module with the perldoc command.
84  
85 perldoc Teng::Plugin::SearchBySQLAbstractMore
86  
87 You can also look for information at:
88  
89 =over 4
90  
91 =item * RT: CPAN's request tracker
92  
93 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Teng-Plugin-SearchBySQLAbstractMore>
94  
95 =item * AnnoCPAN: Annotated CPAN documentation
96  
97 L<http://annocpan.org/dist/Teng-Plugin-SearchBySQLAbstractMore>
98  
99 =item * CPAN Ratings
100  
101 L<http://cpanratings.perl.org/d/Teng-Plugin-SearchBySQLAbstractMore>
102  
103 =item * Search CPAN
104  
105 L<http://search.cpan.org/dist/Teng-Plugin-SearchBySQLAbstractMore/>
106  
107 =back
108  
109  
110 =head1 ACKNOWLEDGEMENTS
111  
112  
113 =head1 LICENSE AND COPYRIGHT
114  
115 Copyright 2012 Ktat.
116  
117 This program is free software; you can redistribute it and/or modify it
118 under the terms of either: the GNU General Public License as published
119 by the Free Software Foundation; or the Artistic License.
120  
121 See http://dev.perl.org/licenses/ for more information.
122  
123  
124 =cut
125  
126 10 1; # End of Teng::Plugin::SearchBySQLAbstractMore::Pager
« blib/lib/Teng/Plugin/SearchBySQLAbstractMore/Pager/MySQLFoundRows.pm ↑ Summary _build/lib/MyBuilder.pm »