DBIx/Class/Relationship/ProxyMethods.pm

filter: Statementstmt 84.0% 42 / 50 Branchbran 66.6% 12 / 18 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 90.9% 10 / 11 Podpod 0.0% 0 / 2 totaltotal 71.4% 65 / 91 CC 31 SCAR 20.6
CC
31
Cov
74%
__ANON__
10.2
artist_name
10.2
cd_title
10.2
CRAP 7.8
« DBIx/Class/DB.pm ↑ Summary DBIx/Class/ResultSetColumn.pm »
1 package # hide from PAUSE
2 DBIx::Class::Relationship::ProxyMethods;
3  
4 308 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 308 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 308 ▶use Sub::Name ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 308 ▶use base qw/DBIx::Class/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 308 our %_pod_inherit_config =
10 (
11 class_map => { 'DBIx::Class::Relationship::ProxyMethods' => 'DBIx::Class::Relationship' }
12 );
13  
14 sub register_relationship {
15 25614 ▶ my ($class, $rel, $info) = @_;
Subroutine register_relationship: called CC=2 SCAR=6.9
Pod undocumented
16 25614 ▶ if (my $proxy_args = $info->{attrs}{proxy}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $proxy_args = $info->{"attrs"}{"proxy"}) 1850 23764 25614
17 1850 $class->proxy_to_related($rel, $proxy_args);
18 }
19 25612 $class->next::method($rel, $info);
20 }
21  
22 sub proxy_to_related {
23 1850 ▶ my ($class, $rel, $proxy_args) = @_;
Subroutine proxy_to_related: called CC=2 SCAR=9.2
Pod undocumented
24 1850 my %proxy_map = $class->_build_proxy_map_from($proxy_args);
25 308 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
26 308 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1848 foreach my $meth_name ( keys %proxy_map ) {
28 2772 my $proxy_to_col = $proxy_map{$meth_name};
29 2772 my $name = join '::', $class, $meth_name;
30 *$name = Sub::Name::subname $name => sub {
31 0 ▶ my $self = shift;
Subroutine link_url: not called CC=4 SCAR=23.3
Subroutine cd_title: called CC=4 SCAR=23.3
32 0 my $relobj = $self->$rel;
33 0 ▶ if (@_ && !defined $relobj) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ and not defined $relobj) 0 0 0
if (@_ and not defined $relobj) 0 11 11
Condition16%1/6
@_ and not defined $relobj
!ll&&!rl&&r
000
@_ and not defined $relobj
!ll&&!rl&&r
1100
MC/DC0%0/2
@_ and not defined $relobj
@_ not defined $relobj
MC/DC0%0/2
@_ and not defined $relobj
@_ not defined $relobj
Truth table0%0/3
A and not(B)
A= @_B= not defined $relobj
ABresult
0X0
100
111
Truth table33%1/3
A and not(B)
A= @_B= not defined $relobj
ABresult
0X0
100
111
34 0 $relobj = $self->create_related($rel, { $proxy_to_col => $_[0] });
35 0 @_ = ();
36 }
37 0 ▶ return ($relobj ? $relobj->$proxy_to_col(@_) : undef);
Branch: 2 branches
BranchTrueFalseTotal
$relobj ? : 0 0 0
$relobj ? : 11 0 11
38 }
39 2772 }
40 }
41  
42 sub _build_proxy_map_from {
43 1850 ▶ my ( $class, $proxy_arg ) = @_;
Subroutine _build_proxy_map_from: called CC=5 SCAR=16.1
44 1850 my $ref = ref $proxy_arg;
45  
46 1850 ▶ if ($ref eq 'HASH') {
Branch: 3 branches
BranchTrueFalseTotal
if ($ref eq 'HASH') { } 924 926 1850
elsif ($ref eq 'ARRAY') { } 616 310 926
elsif ($ref) { } 2 308 310
47 924 return %$proxy_arg;
48 }
49 elsif ($ref eq 'ARRAY') {
50 return map {
51 616 ▶ (ref $_ eq 'HASH')
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'HASH' ? : 308 616 924
52 ? (%$_)
53 : ($_ => $_)
54 } @$proxy_arg;
55 }
56 elsif ($ref) {
57 2 $class->throw_exception("Unable to process the 'proxy' argument $proxy_arg");
58 }
59 else {
60 308 return ( $proxy_arg => $proxy_arg );
61 }
62 }
63  
64 308 1;
« DBIx/Class/DB.pm ↑ Summary DBIx/Class/ResultSetColumn.pm »