Helper/ResultSet/IgnoreWantarray.pm

filter: Statementstmt 100% 13 / 13 Branchbran 100% 2 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 92.0% 23 / 25 CC 3 SCAR 7.0
CC
3
Cov
94%
search
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Helper/Schema/Verifier/ColumnInfo.pm ↑ Summary Helper/IgnoreWantarray.pm »
1 package DBIx::Class::Helper::ResultSet::IgnoreWantarray;
2 54 $DBIx::Class::Helper::ResultSet::IgnoreWantarray::VERSION = '2.033001';
3 # ABSTRACT: Get rid of search context issues
4  
5 54 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 54 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 54 ▶use parent 'DBIx::Class::ResultSet';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub search {
11 212 ▶ $_[0]->throw_exception ('->search is *not* a mutator, calling it in void context makes no sense')
Subroutine search: called CC=3 SCAR=11.1
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless defined wantarray or (caller)[0] =~ /^DBIx\:\:Class\:\:/ 1 211 212
Condition66%2/3
defined wantarray or (caller)[0] =~ /^DBIx\:\:Class\:\:/
l!l&&r!l&&!r
21101
MC/DC50%1/2
defined wantarray or (caller)[0] =~ /^DBIx\:\:Class\:\:/
defined wantarray (caller)[0] =~ /^DBIx\:\:Class\:\:/
Truth table66%2/3
A or B
A= defined wantarrayB= (caller)[0] =~ /^DBIx\:\:Class\:\:/
ABresult
1X1
011
000
12 if !defined wantarray && (caller)[0] !~ /^\QDBIx::Class::/;
13  
14 211 shift->search_rs(@_);
15 }
16  
17 54 1;
18  
19 __END__
20  
21 =pod
22  
23 =head1 NAME
24  
25 DBIx::Class::Helper::ResultSet::IgnoreWantarray - Get rid of search context issues
26  
27 =head1 SYNOPSIS
28  
29 package MyApp::Schema::ResultSet::Foo;
30  
31 __PACKAGE__->load_components(qw{Helper::ResultSet::IgnoreWantarray});
32  
33 ...
34  
35 1;
36  
37 And then else where, like in a controller:
38  
39 my $rs = $self->paginate(
40 $schema->resultset('Foo')->search({
41 name => 'frew'
42 })
43 );
44  
45 =head1 DESCRIPTION
46  
47 This component makes search always return a ResultSet, instead of
48 returning an array of your database in array context. See
49 L<DBIx::Class::Helper::ResultSet/NOTE> for a nice way to apply it to your
50 entire schema.
51  
52 =head1 METHODS
53  
54 =head2 search
55  
56 Override of the default search method to force it to return a ResultSet.
57  
58 =head1 AUTHOR
59  
60 Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
61  
62 =head1 COPYRIGHT AND LICENSE
63  
64 This software is copyright (c) 2016 by Arthur Axel "fREW" Schmidt.
65  
66 This is free software; you can redistribute it and/or modify it under
67 the same terms as the Perl 5 programming language system itself.
68  
69 =cut
« Helper/Schema/Verifier/ColumnInfo.pm ↑ Summary Helper/IgnoreWantarray.pm »