lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm

filter: Statementstmt 94.2% 33 / 35 Branchbran 87.5% 7 / 8 Conditioncond 63.6% 14 / 22 MC/DCmcdc 11.1% 1 / 9 Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 76.8% 63 / 82 CC 12 SCAR 21.2
CC
12
Cov
83%
__ANON__
13.5
__ANON__
2.0
BEGIN
1.0
CRAP 8.4
« lib/Reaction/Role/Meta/Class.pm ↑ Summary lib/Reaction/InterfaceModel/Action/User/ChangePassword.pm »
1 package Reaction::UI::ViewPort::Field::Role::Mutable::Simple;
2  
3 4 ▶use Reaction::Role::Parameterized;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 4 ▶use aliased 'Reaction::UI::ViewPort::Field::Role::Mutable';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use namespace::clean -except => [ qw(meta) ];
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 parameter value_type => (
10 predicate => 'has_value_type'
11 );
12  
13 36 ▶role {
Subroutine __ANON__: called CC=2 SCAR=7.1
14  
15 36 my $p = shift;
16  
17 36 ▶with Mutable, $p->has_value_type ? { value_type => $p->value_type } : ();
Branch: 1 branch
BranchTrueFalseTotal
$p->has_value_type ? : 4 32 36
18  
19 has value_string => (
20 2 ▶ is => 'rw', lazy_build => 1, trigger => sub { shift->adopt_value_string },
Subroutine __ANON__: called CC=1 SCAR=0.0
21 36 );
22  
23 # FIXME - Copied from Reaction::UI::ViewPort::Field::Role::Mutable
24 # as we broke has '+attr' in Moose.
25 36 has is_modified => ( #sould be bool?
26 is => 'ro', writer => '_set_modified',
27 required => 1, default => 0, init_arg => undef
28 );
29  
30 32 ▶around value_string => sub {
Subroutine __ANON__: called CC=11 SCAR=26.0
31 32 my $orig = shift;
32 32 my $self = shift;
33 32 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 6 26 32
34 # recursive call. be VERY careful we don't go infinite here
35 6 my $old = $self->value_string;
36 6 my $new = $_[0];
37 6 ▶ if ((defined $old xor defined $new) || (defined $old && $old ne $new)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $old xor defined $new or defined $old and $old ne $new) { } 2 4 6
Condition50%5/10
defined $old xor defined $new or defined $old and $old ne $new
l!l&&r!l&&!r
024
defined $old xor defined $new
l&&rl&&!r!l&&r!l&&!r
6000
defined $old and $old ne $new
!ll&&!rl&&r
042
MC/DC25%1/4
defined $old xor defined $new or defined $old and $old ne $new
defined $old defined $new defined $old $old ne $new
Truth table25%2/8
A xor B or C and D
A= defined $oldB= defined $newC= defined $oldD= $old ne $new
ABCDresult
10XX1
01XX1
11111
00111
110X0
11100
000X0
00100
38 2 $self->_set_modified(1);
39 } else {
40 4 return;
41 }
42 }
43 28 ▶ if (@_ && defined($_[0]) && !ref($_[0]) && $_[0] eq ''
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and defined $_[0] and not ref $_[0] and $_[0] eq "" and not $self->value_is_required) 0 28 28
Condition75%9/12
@_ and defined $_[0] and not ref $_[0] and $_[0] eq "" and not $self->value_is_required
!ll&&!rl&&r
2710
@_ and defined $_[0] and not ref $_[0] and $_[0] eq ""
!ll&&!rl&&r
2611
@_ and defined $_[0] and not ref $_[0]
!ll&&!rl&&r
2602
@_ and defined $_[0]
!ll&&!rl&&r
2602
MC/DC0%0/5
@_ and defined $_[0] and not ref $_[0] and $_[0] eq "" and not $self->value_is_required
@_ defined $_[0] not ref $_[0] $_[0] eq "" not $self->value_is_required
Truth table50%3/6
A and B and not(C) and D and not(E)
A= @_B= defined $_[0]C= not ref $_[0]D= $_[0] eq ""E= not $self->value_is_required
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
44 && !$self->value_is_required) {
45 0 $self->clear_value;
46 0 return undef;
47 }
48 28 return $self->$orig(@_);
49 36 };
50  
51 # the user needs to implement this because, honestly, you're always going
52 # to need to do something custom and the only common thing really is
53 # "you probably set $self->value at the end"
54 36 requires 'adopt_value_string';
55  
56 36 ▶around accept_events => sub { ('value_string', shift->(@_)) };
Subroutine __ANON__: called CC=1 SCAR=0.0
57  
58 36 ▶around force_events => sub { (value_string => '', shift->(@_)) };
Subroutine __ANON__: called CC=1 SCAR=0.0
59  
60 4 };
61  
62 4 1;
« lib/Reaction/Role/Meta/Class.pm ↑ Summary lib/Reaction/InterfaceModel/Action/User/ChangePassword.pm »