File Coverage

blib/lib/Pinto/Schema/ResultSet/Registration.pm
Criterion Covered Total %
statement 21 24 87.5
branch 1 2 50.0
condition 3 8 37.5
subroutine 7 9 77.7
pod 0 4 0.0
total 32 47 68.0


line stmt bran cond sub pod time code
1             # ABSTRACT: Common queries for Registrations
2              
3 54     54   57126 use utf8;
  54         127  
  54         343  
4              
5             package Pinto::Schema::ResultSet::Registration;
6              
7 54     54   2184 use strict;
  54         121  
  54         1242  
8 54     54   262 use warnings;
  54         114  
  54         1435  
9              
10 54     54   260 use base 'DBIx::Class::ResultSet';
  54         131  
  54         16285  
11              
12             #------------------------------------------------------------------------------
13              
14             our $VERSION = '0.14'; # VERSION
15              
16             #------------------------------------------------------------------------------
17              
18             sub with_package {
19 34     34 0 10808 my ( $self, $where ) = @_;
20              
21 34   50     336 return $self->search( $where || {}, { prefetch => 'package' } );
22             }
23              
24             #------------------------------------------------------------------------------
25              
26             sub with_distribution {
27 34     34 0 17402 my ( $self, $where ) = @_;
28              
29 34   50     352 return $self->search( $where || {}, { prefetch => 'distribution' } );
30             }
31              
32             #------------------------------------------------------------------------------
33              
34             sub with_revision {
35 0     0 0 0 my ( $self, $where ) = @_;
36              
37 0   0     0 return $self->search( $where || {}, { revision => 'distribution' } );
38             }
39              
40             #------------------------------------------------------------------------------
41              
42             sub as_hash {
43 34     34 0 55357 my ( $self, $cb ) = @_;
44              
45 34   50 0   136 $cb ||= sub { return ( $_[0]->id => $_[0] ) };
  0         0  
46 34         170 my %hash = map { $cb->($_) } $self->all;
  45         62845  
47              
48 34 50       11499 return wantarray ? %hash : \%hash;
49             }
50              
51             #------------------------------------------------------------------------------
52             1;
53              
54             __END__
55              
56             =pod
57              
58             =encoding UTF-8
59              
60             =for :stopwords Jeffrey Ryan Thalhammer
61              
62             =head1 NAME
63              
64             Pinto::Schema::ResultSet::Registration - Common queries for Registrations
65              
66             =head1 VERSION
67              
68             version 0.14
69              
70             =head1 AUTHOR
71              
72             Jeffrey Ryan Thalhammer <jeff@stratopan.com>
73              
74             =head1 COPYRIGHT AND LICENSE
75              
76             This software is copyright (c) 2015 by Jeffrey Ryan Thalhammer.
77              
78             This is free software; you can redistribute it and/or modify it under
79             the same terms as the Perl 5 programming language system itself.
80              
81             =cut