Morph/Role/Backend.pm

filter: Statementstmt 79.0% 34 / 43 Branchbran 50.0% 6 / 12 Conditioncond 33.3% 2 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 80.0% 8 / 10 Podpod n/a totaltotal 68.0% 51 / 75 CC 9 SCAR 13.3
CC
9
Cov
69%
__ANON__
6.5
retrieve
6.5
__ANON__
2.5
CRAP 3.8
« Morph.pm ↑ Summary Morph/Backend/DBIC.pm »
1 package Data::Morph::Role::Backend;
2 1 $Data::Morph::Role::Backend::VERSION = '1.140400';
3 2 ▶use MooseX::Role::Parameterized;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use MooseX::Types::Moose(':all');
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 #ABSTRACT: Provides a role to consume to develop specialized backends
8  
9  
10 1 parameter input_type =>
11 (
12 isa => 'Moose::Meta::TypeConstraint',
13 required => 1,
14 );
15  
16  
17 1 parameter set_val =>
18 (
19 isa => CodeRef,
20 required => 1,
21 );
22  
23  
24 1 parameter get_val =>
25 (
26 isa => CodeRef,
27 required => 1,
28 );
29  
30 role
31 6 ▶{
Subroutine __ANON__: called CC=1 SCAR=0.7
32  
33  
34 6 requires 'epilogue';
35  
36 6 my $p = shift;
37  
38  
39 6 has new_instance =>
40 (
41 is => 'ro',
42 isa => CodeRef,
43 required => 1,
44 );
45  
46  
47 has input_type =>
48 (
49 is => 'ro',
50 isa => 'Moose::Meta::TypeConstraint',
51 2 ▶ default => sub { $p->input_type },
Subroutine __ANON__: called CC=1 SCAR=0.0
52 6 );
53  
54  
55 method generate_instance => sub
56 11 ▶ {
Subroutine generate_instance: called CC=1 SCAR=0.0
57 11 my ($self, $input) = @_;
58 11 return $self->new_instance->($input);
59 6 };
60  
61  
62 method retrieve => sub
63 0 ▶ {
Subroutine __ANON__: not called CC=4 SCAR=18.7
Subroutine retrieve: called CC=4 SCAR=18.7
64 0 my ($self, $object, $key, $post) = pos_validated_list
65 (
66 \@_,
67 {isa => __PACKAGE__},
68 {isa => $p->input_type},
69 {isa => Maybe[Str]},
70 {isa => CodeRef, optional => 1},
71 );
72  
73 0 ▶ if(!defined($key) && defined($post))
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $key and defined $post) 0 0 0
if (not defined $key and defined $post) 2 35 37
Condition33%2/6
not defined $key and defined $post
!ll&&!rl&&r
000
not defined $key and defined $post
!ll&&!rl&&r
3502
MC/DC0%0/2
not defined $key and defined $post
not defined $key defined $post
MC/DC50%1/2
not defined $key and defined $post
not defined $key defined $post
Truth table0%0/3
not(A) and B
A= not defined $keyB= defined $post
ABresult
0X0
100
111
Truth table66%2/3
not(A) and B
A= not defined $keyB= defined $post
ABresult
0X0
100
111
74 {
75 0 return $post->();
76 }
77  
78 0 my $val = $p->get_val->($object, $key);
79 0 ▶ $val = $post->($val) if defined($post);
Branch: 2 branches
BranchTrueFalseTotal
if defined $post 0 0 0
if defined $post 2 33 35
80 0 return $val;
81 6 };
82  
83  
84  
85 method store => sub
86 0 ▶ {
Subroutine store: not called CC=2 SCAR=9.2
Subroutine __ANON__: called CC=2 SCAR=9.2
87 0 my ($self, $object, $val, $key, $pre) = pos_validated_list
88 (
89 \@_,
90 {isa => __PACKAGE__},
91 {isa => $p->input_type},
92 {isa => Any},
93 {isa => Str},
94 {isa => CodeRef, optional => 1}
95 );
96  
97 0 ▶ $val = $pre->($val) if defined($pre);
Branch: 2 branches
BranchTrueFalseTotal
if defined $pre 0 0 0
if defined $pre 4 33 37
98 0 $p->set_val->($object, $key, $val);
99 6 };
100 1 };
101 1 1;
102  
103 __END__
« Morph.pm ↑ Summary Morph/Backend/DBIC.pm »