lib/Reaction/UI/ViewPort/Field/Mutable/ChooseOne.pm

filter: Statementstmt 34.8% 15 / 43 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 3 / 6 Podpod 0.0% 0 / 2 totaltotal 25.7% 18 / 70 CC 9 SCAR 28.6
CC
9
Cov
25%
adopt_value_string
30.0
is_current_value
20.0
__ANON__
6.0
CRAP 17.5
« lib/Reaction/UI/ViewPort/Collection.pm ↑ Summary lib/Reaction/InterfaceModel/Action.pm »
1 package Reaction::UI::ViewPort::Field::Mutable::ChooseOne;
2  
3 4 ▶use Reaction::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use namespace::clean -except => [ qw(meta) ];
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 extends 'Reaction::UI::ViewPort::Field';
8  
9 4 with 'Reaction::UI::ViewPort::Field::Role::Mutable::Simple';
10 4 with 'Reaction::UI::ViewPort::Field::Role::Choices';
11 0 ▶sub adopt_value_string {
Subroutine adopt_value_string: not called CC=5 SCAR=34.0
Pod undocumented
12 0 my ($self) = @_;
13 0 my $value = $self->value_string;
14 0 ▶ if(!defined($value) or !length $value) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $value and length $value) 0 0 0
Condition0%0/3
defined $value and length $value
!ll&&!rl&&r
000
MC/DC0%0/2
defined $value and length $value
defined $value length $value
Truth table0%0/3
A and B
A= defined $valueB= length $value
ABresult
0X0
100
111
15 0 $self->clear_value;
16 0 return;
17 }
18 0 ▶ $value = $self->str_to_ident($value) if (!ref $value);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value 0 0 0
19 0 my $attribute = $self->attribute;
20 0 my $checked = $attribute->check_valid_value($self->model, $value);
21 0 ▶ unless (defined $checked) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $checked) 0 0 0
22 0 require Data::Dumper;
23 0 my $serialised = Data::Dumper->new([ $value ])->Indent(0)->Dump;
24 0 $serialised =~ s/^\$VAR1 = //; $serialised =~ s/;$//;
25 0 confess "${serialised} is not a valid value for ${\$attribute->name} on "
26 0 ."${\$attribute->associated_class->name}";
27 }
28 0 $self->value($checked);
29 };
30  
31 0 ▶around _value_string_from_value => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
32 0 my $orig = shift;
33 0 my $self = shift;
34 0 my $value = $self->$orig(@_);
35  
36 # what's up with $value->{value} ?!
37 # and why are we calling obj_to_name here, shouldn't it be obj_to_str
38 # return $self->obj_to_name($value->{value}) if Scalar::Util::blessed($value);
39 # return $self->obj_to_name($value) if blessed $value;
40  
41 0 ▶ return $self->obj_to_str($value) if Scalar::Util::blessed($value);
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($value) 0 0 0
42  
43 0 return "$value"; # force stringify. might work. probably won't.
44 4 };
45 0 ▶sub is_current_value {
Subroutine is_current_value: not called CC=4 SCAR=30.0
Pod undocumented
46 0 my ($self, $check_value) = @_;
47 0 ▶ return unless $self->_model_has_value;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_model_has_value 0 0 0
48 0 my $our_value = $self->value;
49 0 ▶ return unless defined($our_value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $our_value 0 0 0
50 0 ▶ $check_value = $self->obj_to_str($check_value) if ref($check_value);
Branch: 1 branch
BranchTrueFalseTotal
if ref $check_value 0 0 0
51 0 return $self->obj_to_str($our_value) eq $check_value;
52 };
53  
54 4 __PACKAGE__->meta->make_immutable;
55  
56  
57 4 1;
« lib/Reaction/UI/ViewPort/Collection.pm ↑ Summary lib/Reaction/InterfaceModel/Action.pm »