API/StoredResultSource.pm

filter: Statementstmt 97.7% 43 / 44 Branchbran 88.8% 16 / 18 Conditioncond 83.3% 10 / 12 MC/DCmcdc 57.1% 4 / 7 Subroutinesub 100% 12 / 12 Podpod 100% 5 / 5 totaltotal 91.8% 90 / 98 CC 14 SCAR 16.1
CC
14
Cov
93%
check_has_relation
10.1
__ANON__
2.5
check_column_relation
2.0
CRAP 5.0
« API.pm ↑ Summary API/Validator/Visitor.pm »
1 package Catalyst::Controller::DBIC::API::StoredResultSource;
2 16 $Catalyst::Controller::DBIC::API::StoredResultSource::VERSION = '2.009000';
3 #ABSTRACT: Provides accessors for static resources
4  
5 16 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 16 ▶use MooseX::Types::Moose(':all');
Subroutine BEGIN: called CC=1 SCAR=0.0
7 16 ▶use Catalyst::Controller::DBIC::API::Types(':all');
Subroutine BEGIN: called CC=1 SCAR=0.0
8 16 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 16 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 16 requires '_application';
12  
13  
14 16 has 'class' => ( is => 'ro', isa => Str, writer => '_set_class' );
15  
16  
17 16 has 'result_class' => (
18 is => 'ro',
19 isa => Maybe [Str],
20 default => 'DBIx::Class::ResultClass::HashRefInflator'
21 );
22  
23  
24 693 ▶sub stored_result_source {
Subroutine stored_result_source: called CC=1 SCAR=0.0
Pod documented
25 693 return shift->stored_model->result_source;
26 }
27  
28  
29 693 ▶sub stored_model {
Subroutine stored_model: called CC=1 SCAR=0.0
Pod documented
30 693 return $_[0]->_application->model( $_[0]->class );
31 }
32  
33  
34 571 ▶sub check_has_column {
Subroutine check_has_column: called CC=2 SCAR=6.9
Pod documented
35 571 my ( $self, $col ) = @_;
36 571 ▶ die "Column '$col' does not exist in ResultSet '${\$self->class}'"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->stored_result_source->has_column($col) 1 570 571
37 unless $self->stored_result_source->has_column($col);
38 }
39  
40  
41 77 ▶sub check_has_relation {
Subroutine check_has_relation: called CC=10 SCAR=23.1
Pod documented
42 77 my ( $self, $rel, $other, $nest, $static ) = @_;
43  
44 77 ▶ $nest ||= $self->stored_result_source;
Condition66%2/3
$nest ||= $self->stored_result_source
l!l&&r!l&&!r
13640
MC/DC0%0/2
$nest ||= $self->stored_result_source
$nest $self->stored_result_source
Truth table66%2/3
A ||= B
A= $nestB= $self->stored_result_source
ABresult
1X1
011
000
45  
46 77 ▶ if ( HashRef->check($other) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (HashRef()->check($other)) { } 20 57 77
47 20 my $rel_src = $nest->related_source($rel);
48 13 ▶ die "Relation '$rel_src' does not exist" if not defined($rel_src);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rel_src 0 13 13
49  
50 13 ▶ while ( my ( $k, $v ) = each %$other ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$other) 13 8 21
51 13 $self->check_has_relation( $k, $v, $rel_src, $static );
52 }
53 }
54 else {
55 57 ▶ return 1 if $static && ArrayRef->check($other) && $other->[0] eq '*';
Branch: 1 branch
BranchTrueFalseTotal
if $static and ArrayRef()->check($other) and $other->[0] eq "*" 30 27 57
Condition83%5/6
$static and ArrayRef()->check($other) and $other->[0] eq "*"
!ll&&!rl&&r
27030
$static and ArrayRef()->check($other)
!ll&&!rl&&r
24330
MC/DC66%2/3
$static and ArrayRef()->check($other) and $other->[0] eq "*"
$static ArrayRef()->check($other) $other->[0] eq "*"
Truth table75%3/4
A and B and C
A= $staticB= ArrayRef()->check($other)C= $other->[0] eq "*"
ABCresult
0XX0
10X0
1100
1111
56 27 ▶ die "Relation '$rel' does not exist in ${\$nest->from}"
Branch: 1 branch
BranchTrueFalseTotal
unless $nest->has_relationship($rel) or $nest->has_column($rel) 8 19 27
Condition100%3/3
$nest->has_relationship($rel) or $nest->has_column($rel)
l!l&&r!l&&!r
5148
MC/DC100%2/2
$nest->has_relationship($rel) or $nest->has_column($rel)
$nest->has_relationship($rel) $nest->has_column($rel)
Truth table100%3/3
A or B
A= $nest->has_relationship($rel)B= $nest->has_column($rel)
ABresult
1X1
011
000
57 unless $nest->has_relationship($rel) || $nest->has_column($rel);
58 19 return 1;
59 }
60 }
61  
62  
63 632 ▶sub check_column_relation {
Subroutine check_column_relation: called CC=2 SCAR=7.0
Pod documented
64 632 my ( $self, $col_rel, $static ) = @_;
65  
66 632 ▶ if ( HashRef->check($col_rel) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (HashRef()->check($col_rel)) { } 61 571 632
67 61 ▶ try {
Subroutine __ANON__: called CC=2 SCAR=6.9
68 61 ▶ while ( my ( $k, $v ) = each %$col_rel ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$col_rel) 61 46 107
69 61 $self->check_has_relation( $k, $v, undef, $static );
70 }
71 }
72 15 ▶ catch {
Subroutine __ANON__: called CC=2 SCAR=9.2
73 # not a relation but a column with a predicate
74 15 ▶ while ( my ( $k, undef ) = each %$col_rel ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($k, undef) = each %$col_rel) 0 15 15
75 0 $self->check_has_column($k);
76 }
77 }
78 61 }
79 else {
80 571 $self->check_has_column($col_rel);
81 }
82 }
83  
84 16 1;
85  
86 __END__
« API.pm ↑ Summary API/Validator/Visitor.pm »