Sub/HandlesVia/Toolkit/SubAccessorSmall.pm

filter: Statementstmt 100% 43 / 43 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 3 totaltotal 89.2% 58 / 65 SCAR 16.1
CC
5
Cov
92%
code_generator_for_attribute
4.1
clean_spec
2.0
BEGIN
1.0
CRAP 5.0
« Lexical/Accessor.pm ↑ Summary
1 1 ▶use 5.008003;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 ▶no warnings qw( void once uninitialized );
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package Sub::HandlesVia::Toolkit::SubAccessorSmall;
7  
8 1 our $AUTHORITY = 'cpan:TOBYINK';
9 1 our $VERSION = '0.014';
10  
11 1 ▶use Sub::HandlesVia::Toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 our @ISA = 'Sub::HandlesVia::Toolkit';
13 1 $ISA[0]->VERSION( '0.025' );
14  
15 sub new {
16 1 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
17 1 bless { @_ } => $class;
18 }
19  
20 sub _attr {
21 1 ▶ shift->{attr};
Subroutine _attr: called CC=1 SCAR=0.0
22 }
23  
24 sub _handles_map {
25 1 ▶ shift->{handles_map};
Subroutine _handles_map: called CC=1 SCAR=0.0
26 }
27  
28 sub clean_spec {
29 1 ▶ my ( $self, $target, $attr, $spec ) = @_;
Subroutine clean_spec: called CC=2 SCAR=7.0
Pod undocumented
30 1 ▶ if ( 'ARRAY' eq ref $spec->{handles} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("ARRAY" eq ref $spec->{"handles"}) 1 0 1
31 1 my %tmp = @{ $spec->{handles} };
32 1 $spec->{handles} = \%tmp;
33 }
34 1 return $self->SUPER::clean_spec( $target, $attr, $spec );
35 }
36  
37 sub code_generator_for_attribute {
38 1 ▶ my ( $self, $target, $attr ) = @_;
Subroutine code_generator_for_attribute: called CC=4 SCAR=14.0
Pod undocumented
39 1 my $realattr = $self->_attr;
40 1 my $handles_map = $self->_handles_map;
41
42 {
43 1 my $reader = $realattr->reader;
44 1 my $writer = $realattr->writer;
45 my $default =
46 ref($realattr->{default}) ? $realattr->{default} :
47 length($realattr->{builder}) ? $realattr->{builder} :
48 1 ▶ undef;
Branch: 2 branches
BranchTrueFalseTotal
ref $realattr->{'default'} ? : 0 1 1
length $realattr->{'builder'} ? : 0 1 1
49 1 ▶ $attr = [ $reader, $writer, $default ? $default : () ];
Branch: 1 branch
BranchTrueFalseTotal
$default ? : 0 1 1
50 }
51
52 1 my $gen = $self->SUPER::code_generator_for_attribute( $target, $attr );
53
54 $gen->method_installer( sub {
55 2 ▶ my ( $method_name, $coderef ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
56 2 my $real_destination = $handles_map->{$method_name};
57 2 $realattr->install_coderef( $real_destination, $coderef );
58 1 } );
59
60 1 return $gen;
61 }
62  
63 1 1;
« Lexical/Accessor.pm ↑ Summary