Privacy/Meta/Attribute/Privacy.pm

filter: Statementstmt 86.0% 68 / 79 Branchbran 60.0% 6 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 86.6% 13 / 15 Podpod n/a totaltotal 83.6% 87 / 104 CC 6 SCAR 4.8
CC
6
Cov
83%
__ANON__
2.5
__ANON__
2.0
foo
2.0
CRAP 1.6
« Privacy/Meta/Method/Protected.pm ↑ Summary Privacy/Meta/Attribute/Private.pm »
1 package MooseX::Privacy::Meta::Attribute::Privacy;
2 3 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 $MooseX::Privacy::Meta::Attribute::Privacy::VERSION = '0.05';
4 }
5  
6 3 ▶use MooseX::Role::Parameterized;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 parameter level => (isa => 'Str', is => 'ro', required => 1,);
9  
10 3 ▶role {
Subroutine __ANON__: called CC=1 SCAR=0.1
11 3 my $p = shift;
12  
13 3 my $check_method = '_check_' . $p->level;
14 3 my $push_method = '_push_' . $p->level . '_attribute';
15 3 my $local_attribute = 'local_' . $p->level . '_attributes';
16  
17 2 ▶ method _generate_accessor_method => sub {
Subroutine _generate_accessor_method: called CC=2 SCAR=6.9
Subroutine __ANON__: called CC=2 SCAR=6.9
18 2 my $meta = shift;
19 2 my $attr = $meta->associated_attribute;
20 2 my $package_name = $attr->associated_class->name;
21  
22 2 my $class = $package_name->meta;
23 2 ▶ if ($class->meta->has_attribute($local_attribute)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($class->meta->has_attribute($local_attribute)) 1 1 2
if ($class->meta->has_attribute($local_attribute)) 2 0 2
24 1 $class->$push_method($attr->name);
25 }
26  
27 8 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
Subroutine foo: called CC=2 SCAR=6.9
28 8 my $self = shift;
29 8 my $caller = (scalar caller());
30 8 my $name = $self->meta->name;
31 8 $meta->$check_method($caller, $attr->name, $package_name, $name);
32 5 ▶ $attr->set_value($self, $_[0]) if scalar(@_) == 1;
Branch: 2 branches
BranchTrueFalseTotal
if scalar @_ == 1 2 3 5
if scalar @_ == 1 0 2 2
33 5 $attr->get_value($self);
34 2 };
35 3 };
36  
37 1 ▶ method _generate_reader_method => sub {
Subroutine __ANON__: called CC=1 SCAR=0.4
38 1 my $meta = shift;
39 1 my $attr = $meta->associated_attribute;
40 1 my $package_name = $attr->associated_class->name;
41  
42 1 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=9.2
43 1 my $self = shift;
44 1 my $caller = (scalar caller());
45 1 my $name = $self->meta->name;
46 1 $meta->$check_method($caller, $attr->name, $package_name, $name);
47 0 ▶ confess "Cannot assign a value to a read-only accessor" if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
48 0 $attr->get_value($self);
49 1 };
50 3 };
51  
52 0 ▶ method _generate_writer_method => sub {
Subroutine _generate_writer_method: not called CC=1 SCAR=6.9
53 0 my $meta = shift;
54 0 my $attr = $meta->associated_attribute;
55 0 my $package_name = $attr->associated_class->name;
56  
57 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
58 0 my $self = shift;
59 0 my $caller = (scalar caller());
60 0 my $name = $self->meta->name;
61 0 $meta->$check_method($caller, $attr->name, $package_name, $name);
62 0 $attr->set_value($self, $_[1]);
63 0 };
64 3 };
65  
66 1 ▶ method _generate_predicate_method => sub {
Subroutine _generate_predicate_method: called CC=1 SCAR=0.0
67 1 my $meta = shift;
68 1 my $attr = $meta->associated_attribute;
69 1 my $package_name = $attr->associated_class->name;
70  
71 3 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
72 3 my $self = shift;
73 3 my $caller = (scalar caller());
74 3 my $name = $self->meta->name;
75 3 $meta->$check_method($caller, $attr->name, $package_name, $name);
76 2 $attr->has_value($self);
77 1 };
78 3 };
79  
80 1 ▶ method _generate_clearer_method => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
81 1 my $meta = shift;
82 1 my $attr = $meta->associated_attribute;
83 1 my $package_name = $attr->associated_class->name;
84  
85 2 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
86 2 my $self = shift;
87 2 my $caller = (scalar caller());
88 2 my $name = $self->meta->name;
89 2 $meta->$check_method($caller, $attr->name, $package_name, $name);
90 1 $attr->clear_value($self);
91 1 };
92 3 };
93 3 };
94  
95 3 1;
96  
97 __END__
« Privacy/Meta/Method/Protected.pm ↑ Summary Privacy/Meta/Attribute/Private.pm »