lib/AutoCode/ModuleModel.pm

filter: Statementstmt 85.2% 58 / 68 Branchbran 68.7% 11 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 9 / 12 Podpod 0.0% 0 / 4 totaltotal 78.0% 78 / 100 CC 15 SCAR 17.8
CC
15
Cov
82%
__initialize_value_attributes
11.2
_initialize
3.0
__initialize_directive_attributes
3.0
CRAP 5.9
« blib/lib/AutoCode/MarshalRoot.pm ↑ Summary lib/AutoCode/AccessorMaker.pm »
1 package AutoCode::ModuleModel;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use AutoCode::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 our @ISA=qw(AutoCode::Root);
5 5 ▶use AutoCode::AccessorMaker (
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 '$' => [qw(schema type _value_attributes _directive_attributes)],
7 '@' => ['scalar_attribute', 'array_attribute', 'scalar_slot', 'array_slot',
8 [qw(scalar_child scalar_children)], [qw(array_child array_children)],
9 'isa']
10 5 );
11  
12 5 ▶use AutoCode::AttributeType;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 14 ▶sub _initialize {
Subroutine _initialize: called CC=3 SCAR=11.1
15 14 my ($self, @args)=@_;
16 14 my ($schema, $type)=$self->_rearrange([qw(SCHEMA TYPE)], @args);
17 14 ▶ defined $schema or $self->throw("NO schema!");
Branch: 1 branch
BranchTrueFalseTotal
defined $schema or $self->throw("NO schema!") 14 0 14
18 14 $self->schema($schema);
19 14 ▶ defined $type or $self->throw("NO type!");
Branch: 1 branch
BranchTrueFalseTotal
defined $type or $self->throw("NO type!") 14 0 14
20 14 $self->type($type);
21  
22 14 $self->__initialize_value_attributes; # value_attribute, directive_attribute
23 14 $self->__initialize_directive_attributes;
24  
25 }
26  
27 14 ▶sub __initialize_value_attributes {
Subroutine __initialize_value_attributes: called CC=11 SCAR=24.2
28 14 my $self=shift;
29 14 my ($schema, $type)=($self->schema, $self->type);
30 14 my %module =%{$schema->_get_module_definition($type)};
31
32 14 my (%value_attrs, %directive_attrs);
33 14 $value_attrs{$_}=$module{$_} foreach grep /^[a-zA-Z_]/, keys %module;
34 14 $directive_attrs{$_}=$module{$_} foreach grep /^\W/, keys %module;
35 14 $self->_value_attributes(\%value_attrs);
36 14 $self->_directive_attributes(\%directive_attrs);
37
38 # initialize_value_attributes
39 $self->add_scalar_attribute($_)
40 14 foreach grep {$value_attrs{$_}=~/^\$/} keys %value_attrs;
41 $self->add_array_attribute($_)
42 14 foreach grep {$value_attrs{$_}=~/^\@/} keys %value_attrs;
43  
44 14 foreach my $attr ($self->get_scalar_attributes){
45 29 my $kind = ($self->_classify_value_attribute($attr))[1];
46 29 ▶ if($kind =~ /^[PE]$/){ $self->add_scalar_slot($attr);
Branch: 2 branches
BranchTrueFalseTotal
if ($kind =~ /^[PE]$/) { } 19 10 29
elsif ($kind eq 'M') { } 10 0 10
47 10 }elsif($kind eq 'M'){ $self->add_scalar_child($attr);
48 0 }else{ $self->throw("$kind of Attr[$attr] is not valid kind"); }
49 }
50 14 foreach my $attr ($self->get_array_attributes){
51 10 my $kind = ($self->_classify_value_attribute($attr))[1];
52 10 ▶ if($kind eq 'P'){ $self->add_array_slot($attr); }
Branch: 2 branches
BranchTrueFalseTotal
if ($kind eq 'P') { } 5 5 10
elsif ($kind eq 'M') { } 5 0 5
53 5 elsif($kind eq 'M'){ $self->add_array_child($attr); }
54 0 else{ $self->throw("$kind of Attr[$attr] is not valid kind"); }
55 }
56 }
57  
58  
59 14 ▶sub __initialize_directive_attributes {
Subroutine __initialize_directive_attributes: called CC=3 SCAR=11.0
60 14 my $self=shift;
61 14 my %d_attrs=%{$self->_directive_attributes};
62 14 ▶ if(exists $d_attrs{'@ISA'}){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $d_attrs{"\@ISA"}) 8 6 14
63 8 my $isa=$d_attrs{'@ISA'};
64 8 ▶ $self->add_isa((ref($isa) eq'ARRAY')?@$isa:$isa);
Branch: 1 branch
BranchTrueFalseTotal
ref $isa eq 'ARRAY' ? : 0 8 8
65 }
66 }
67  
68 0 ▶sub get_all_value_attributes {
Subroutine get_all_value_attributes: not called CC=1 SCAR=6.9
Pod undocumented
69 0 return keys %{shift->_value_attributes};
70 }
71  
72 39 ▶sub get_value_attribute {
Subroutine get_value_attribute: called CC=1 SCAR=0.0
Pod undocumented
73 39 my ($self, $attr)=@_;
74 39 my %attrs=%{$self->_value_attributes};
75 39 return $attrs{$attr};
76 }
77  
78 0 ▶sub get_all_directive_attributes {
Subroutine get_all_directive_attributes: not called CC=1 SCAR=6.9
Pod undocumented
79 0 keys %{shift->_directive_attributes};
80 }
81  
82 0 ▶sub get_directive_attribute {
Subroutine get_directive_attribute: not called CC=1 SCAR=6.9
Pod undocumented
83 0 my ($self, $attr)=@_;
84 0 my %attrs=%{$self->_directive_attributes};
85 0 return $attrs{$attr};
86 }
87  
88 39 ▶sub _classify_value_attribute {
Subroutine _classify_value_attribute: called CC=1 SCAR=0.0
89 39 my ($self, $attr)=@_;
90 39 my $value = $self->get_value_attribute($attr);
91
92 39 return AutoCode::AttributeType->classify($value);
93
94 }
95  
96  
97 5 1;
« blib/lib/AutoCode/MarshalRoot.pm ↑ Summary lib/AutoCode/AccessorMaker.pm »