lib/Reaction/Role/Meta/Attribute.pm

filter: Statementstmt 61.3% 27 / 44 Branchbran 60.0% 12 / 20 Conditioncond 40.0% 6 / 15 MC/DCmcdc 20.0% 2 / 10 Subroutinesub 37.5% 3 / 8 Podpod n/a totaltotal 51.5% 50 / 97 CC 17 SCAR 18.9
CC
17
Cov
57%
__ANON__
8.4
__ANON__
7.8
get_clearer_method_ref
7.8
CRAP 6.6
« lib/Reaction/UI/WidgetClass/_OVER.pm ↑ Summary lib/Reaction/InterfaceModel/Action/User/ResetPassword.pm »
1 package Reaction::Role::Meta::Attribute;
2  
3 9 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 #is => 'Bool' ? or leave it open
6 9 has lazy_fail =>
7 (is => 'ro', reader => 'is_lazy_fail', required => 1, default => 0);
8  
9 9 ▶if ( $Moose::VERSION < 1.09 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Moose::VERSION < "1.09") 0 9 9
10 0 ▶ around legal_options_for_inheritance => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
11 0 return (shift->(@_), qw/valid_values/);
12 0 };
13 }
14  
15 1317 ▶around _process_options => sub {
Subroutine __ANON__: called CC=8 SCAR=21.2
16 1317 my $super = shift;
17 1317 my ($class, $name, $options) = @_;
18  
19 1317 my $fail = $options->{lazy_fail};
20  
21 1317 ▶ if ( $fail ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fail) 115 1202 1317
22 confess("You may not use both lazy_build and lazy_fail for one attribute")
23 115 ▶ if $fail && $options->{lazy_build};
Branch: 1 branch
BranchTrueFalseTotal
if $fail and $options->{"lazy_build"} 0 115 115
Condition33%1/3
$fail and $options->{"lazy_build"}
!ll&&!rl&&r
01150
MC/DC0%0/2
$fail and $options->{"lazy_build"}
$fail $options->{"lazy_build"}
Truth table33%1/3
A and B
A= $failB= $options->{"lazy_build"}
ABresult
0X0
100
111
24  
25 115 $options->{lazy} = 1;
26 115 $options->{required} = 1;
27 0 ▶ $options->{default} = sub { confess "${name} must be provided before calling reader" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
28 }
29  
30 #we are using this everywhere so might as well move it here.
31 $options->{predicate} ||= ($name =~ /^_/) ? "_has${name}" : "has_${name}"
32 1317 ▶ if !$options->{required} || $options->{lazy};
Branch: 2 branches
BranchTrueFalseTotal
if not $options->{"required"} or $options->{"lazy"} 939 378 1317
$name =~ /^_/ ? : 57 661 718
Condition83%5/6
not $options->{"required"} or $options->{"lazy"}
l!l&&r!l&&!r
727212378
$options->{"predicate"} ||= $name =~ /^_/ ? "_has$name" : "has_$name"
l!l&&r!l&&!r
2217180
MC/DC100%2/2
not $options->{"required"} or $options->{"lazy"}
not $options->{"required"} $options->{"lazy"}
MC/DC0%0/2
$options->{"predicate"} ||= $name =~ /^_/ ? "_has$name" : "has_$name"
$options->{"predicate"} $name =~ /^_/ ? "_has$name" : "has_$name"
Truth table100%3/3
not(A) or B
A= not $options->{"required"}B= $options->{"lazy"}
ABresult
1X1
011
000
Truth table66%2/3
A ||= B
A= $options->{"predicate"}B= $name =~ /^_/ ? "_has$name" : "has_$name"
ABresult
1X1
011
000
33  
34 1317 $super->($class, $name, $options);
35 9 };
36  
37 9 foreach my $type (qw(clearer predicate)) {
38  
39 18 my $value_meth = do {
40 18 ▶ if ($type eq 'clearer') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'clearer') { } 9 9 18
elsif ($type eq 'predicate') { } 9 0 9
41 9 'clear_value'
42 } elsif ($type eq 'predicate') {
43 9 'has_value'
44 } else {
45 0 confess "NOTREACHED";
46 }
47 };
48  
49 0 ▶ __PACKAGE__->meta->add_method("get_${type}_method" => sub {
Subroutine get_clearer_method: not called CC=2 SCAR=17.9
50 0 my $self = shift;
51 0 my $info = $self->$type;
52 0 ▶ return $info unless ref $info;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $info 0 0 0
53 0 my ($name) = %$info;
54 0 return $name;
55 18 });
56  
57 0 ▶ __PACKAGE__->meta->add_method("get_${type}_method_ref" => sub {
Subroutine get_clearer_method_ref: not called CC=3 SCAR=20.5
Subroutine __ANON__: called CC=3 SCAR=20.5
58 0 my $self = shift;
59 0 ▶ if ((my $name = $self->${\"get_${type}_method"}) && $self->associated_class) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $name = $self->${\("get_${type}_method");} and $self->associated_class) { } 0 0 0
if (my $name = $self->${\("get_${type}_method");} and $self->associated_class) { } 1247 0 1247
Condition0%0/6
my $name = $self->${\("get_${type}_method");} and $self->associated_class
!ll&&!rl&&r
000
my $name = $self->${\("get_${type}_method");} and $self->associated_class
!ll&&!rl&&r
000
MC/DC0%0/2
my $name = $self->${\("get_${type}_method");} and $self->associated_class
my $name = $self->${\("get_${type}_method");} $self->associated_class
MC/DC0%0/2
my $name = $self->${\("get_${type}_method");} and $self->associated_class
my $name = $self->${\("get_${type}_method");} $self->associated_class
Truth table0%0/3
A and B
A= my $name = $self->${\("get_${type}_method");}B= $self->associated_class
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= my $name = $self->${\("get_${type}_method");}B= $self->associated_class
ABresult
0X0
100
111
60 0 return $self->associated_class->get_method($name);
61 } else {
62 0 ▶ return sub { $self->$value_meth(@_); }
Subroutine __ANON__: not called CC=1 SCAR=6.9
63 0 }
64 18 });
65 }
66  
67 9 1;
68  
69 __END__;
« lib/Reaction/UI/WidgetClass/_OVER.pm ↑ Summary lib/Reaction/InterfaceModel/Action/User/ResetPassword.pm »