blib/lib/DBIx/Class/ResultSet/Data/Pageset.pm

filter: Statementstmt 73.6% 14 / 19 Branchbran n/a Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 4 / 5 Podpod 100% 1 / 1 totaltotal 61.2% 19 / 31 CC 3 SCAR 17.4
CC
3
Cov
61%
pageset
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.7
↑ Summary
1 package DBIx::Class::ResultSet::Data::Pageset;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use base qw( DBIx::Class::ResultSet );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Data::Pageset ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 our $VERSION = '0.06';
11  
12 =head1 NAME
13  
14 DBIx::Class::ResultSet::Data::Pageset - Get a Data::Pageset pager from a resultset
15  
16 =head1 SYNOPSIS
17  
18 # in your resultsource class
19 __PACKAGE__->resultset_class( 'DBIx::Class::ResultSet::Data::Pageset' );
20
21 # in your calling code
22 my $rs = $schema->resultset('Foo')->search( { }, { pages_per_set => 5 } );
23 my $pager = $rs->pageset;
24
25 # sliding pager
26 my $rs2 = $schema->resultset('Foo')->search( { }, { pageset_mode => 'slide' } );
27  
28 =head1 DESCRIPTION
29  
30 This is a simple way to allow you to get a L<Data::Pageset> object for paging
31 rather than the standard L<Data::Page> object.
32  
33 =head1 INSTALLATION
34  
35 perl Makefile.PL
36 make
37 make test
38 make install
39  
40 =head1 METHODS
41  
42 =head2 pageset( )
43  
44 Returns a L<Data::Pageset> object for paging. This will grab the C<pages_per_set>
45 option (default: C<10>) and the C<pageset_mode> option (default: C<fixed>) from the
46 resultset attributes.
47  
48 =cut
49  
50 0 ▶sub pageset {
Subroutine pageset: not called CC=3 SCAR=24.8
Pod documented
51 0 my( $self ) = @_;
52 0 my $pager = $self->pager;
53 0 my $attrs = $self->{attrs};
54  
55 return Data::Pageset->new( {
56 0 ▶ ( map { $_ => $pager->$_ } qw(
Condition0%0/4
$attrs->{'pages_per_set'} || 10
l!l
00
$attrs->{'pageset_mode'} || 'fixed'
l!l
00
MC/DC0%0/1
$attrs->{'pages_per_set'} || 10
$attrs->{'pages_per_set'}
MC/DC0%0/1
$attrs->{'pageset_mode'} || 'fixed'
$attrs->{'pageset_mode'}
Truth table0%0/2
A
A= $attrs->{'pages_per_set'}
Aresult
11
00
Truth table0%0/2
A
A= $attrs->{'pageset_mode'}
Aresult
11
00
57 entries_per_page
58 total_entries
59 current_page
60 ), ),
61 pages_per_set => $attrs->{ pages_per_set } || 10,
62 0 mode => $attrs->{ pageset_mode } || 'fixed',
63 } );
64 }
65  
66 =head1 AUTHOR
67  
68 Brian Cassidy E<lt>bricas@cpan.orgE<gt>
69  
70 =head1 COPYRIGHT AND LICENSE
71  
72 Copyright 2007-2009 by Brian Cassidy
73  
74 This library is free software; you can redistribute it and/or modify
75 it under the same terms as Perl itself.
76  
77 =head1 SEE ALSO
78  
79 =over 4
80  
81 =item * L<DBIx::Class>
82  
83 =item * L<Data::Pageset>
84  
85 =back
86  
87 =cut
88  
89 2 1;
↑ Summary