MOP/Slot/Initializer.pm

filter: Statementstmt 100% 32 / 32 Branchbran 83.3% 5 / 6 Conditioncond 66.6% 4 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 81.8% 9 / 11 Podpod 100% 3 / 3 totaltotal 85.4% 53 / 62 CC 6 SCAR 6.4
CC
6
Cov
93%
BUILDARGS
3.1
CREATE
3.0
BUILD
2.0
CRAP 1.9
« MOP/Method/Attribute.pm ↑ Summary MOP/Class.pm »
1 package MOP::Slot::Initializer;
2 # ABSTRACT: A representation of a class slot initializer
3  
4 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 8 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 ▶use MOP::Internal::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 8 our $VERSION = '0.14';
12 8 our $AUTHORITY = 'cpan:STEVAN';
13  
14 8 ▶use parent 'UNIVERSAL::Object::Immutable';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 8 ▶our %HAS; BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
17 %HAS = (
18 0 ▶ default => sub {},
Subroutine __ANON__: not called CC=1 SCAR=0.0
19 0 ▶ required => sub {},
Subroutine __ANON__: not called CC=1 SCAR=0.0
20 )
21 8 }
22  
23 4 ▶sub BUILDARGS {
Subroutine BUILDARGS: called CC=3 SCAR=11.3
Pod documented
24 4 my $class = shift;
25 4 my $args = $class->SUPER::BUILDARGS( @_ );
26  
27 Carp::confess('Cannot have both a default and be required in the same initializer')
28 4 ▶ if $args->{default} && $args->{required};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"default"} and $args->{"required"} 0 4 4
Condition66%2/3
$args->{"default"} and $args->{"required"}
!ll&&!rl&&r
310
MC/DC0%0/2
$args->{"default"} and $args->{"required"}
$args->{"default"} $args->{"required"}
Truth table66%2/3
A and B
A= $args->{"default"}B= $args->{"required"}
ABresult
0X0
100
111
29  
30 4 return $args;
31 }
32  
33 4 ▶sub CREATE {
Subroutine CREATE: called CC=3 SCAR=11.0
Pod documented
34 4 my ($class, $args) = @_;
35  
36 4 my $code;
37 4 ▶ if ( my $message = $args->{required} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $message = $args->{'required'}) { } 1 3 4
38 1 $code = eval 'sub { die \''.$message.'\' }';
39 }
40 else {
41 3 ▶ $code = $args->{default} || eval 'sub { undef }';
Condition66%2/3
$args->{'default'} || eval 'sub { undef }'
l!l&&r!l&&!r
120
MC/DC0%0/2
$args->{'default'} || eval 'sub { undef }'
$args->{'default'} eval 'sub { undef }'
Truth table66%2/3
A || B
A= $args->{'default'}B= eval 'sub { undef }'
ABresult
1X1
011
000
42 }
43  
44 4 return $code;
45 }
46  
47 4 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=6.9
Pod documented
48 4 my ($self, $params) = @_;
49  
50 MOP::Internal::Util::SET_COMP_STASH_FOR_CV( $self, $params->{within_package} )
51 4 ▶ if $params->{within_package};
Branch: 1 branch
BranchTrueFalseTotal
if $params->{"within_package"} 2 2 4
52 }
53  
54 8 1;
55  
56 __END__
« MOP/Method/Attribute.pm ↑ Summary MOP/Class.pm »