blib/lib/MooX/Private/Attribute.pm

filter: Statementstmt 100% 21 / 21 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 31 / 31 CC 3 SCAR 4.1
CC
3
Cov
100%
__ANON__
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.5
↑ Summary
1 package MooX::Private::Attribute;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use MooX::ReturnModifiers;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 our $VERSION = '1.04';
6  
7 1 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
8 1 my $target = caller;
9 1 my %modifiers = return_modifiers( $target, [qw/before around/] );
10 $modifiers{around}->(
11 'has',
12 2 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
13 2 my ( $orig, $attr, %opts ) = @_;
14 2 my $private = delete $opts{private};
15 2 $orig->( $attr, %opts );
16 $modifiers{before}->(
17 $attr,
18 5 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
19 5 my $private_caller = caller(1);
20 5 ▶ if ( $private_caller ne $target ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($private_caller ne $target) 2 3 5
21 2 die
22 "cannot call private attribute $attr from $private_caller";
23 }
24 }
25 2 ▶ ) if $private;
Branch: 1 branch
BranchTrueFalseTotal
if $private 1 1 2
26 }
27 1 );
28 }
29  
30 1 1;
31  
32 __END__
↑ Summary