ReadWritePrivate/Role/Attribute.pm untested

filter: Statementstmt 0.0% 0 / 54 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 0.0% 0 / 7 Podpod n/a totaltotal 0.0% 0 / 103 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package MooseX::Accessors::ReadWritePrivate::Role::Attribute;
2  
3 use 5.008;
4 use utf8;
5  
6 use strict;
7 use warnings;
8  
9  
10 use version; our $VERSION = qv('v1.4.0');
11  
12  
13 use Moose::Role 2.0;
14  
15  
16 my $TRUE = 1;
17 my $FALSE = 0;
18  
19  
20 before _process_options => sub {
21 my ($class, $name, $options) = @_;
22  
23 my $is = $options->{is};
24 if (
25 $is
26 and not ( exists $options->{reader} and exists $options->{writer} )
27 and $is =~ m<
28 \A
29 (?:
30 r (p)? w (p)?
31 | ( [rw] ) o (p)?
32 )
33 \z
34 >xms
35 ) {
36 my ($read_private, $write_private, $read_or_write_only, $only_private) =
37 ($1, $2, $3, $4);
38  
39 if (
40 $name =~ m<
41 \A
42 ( _* )
43 ( [^_] .* )?
44 \z
45 >xms
46 ) {
47 my ($scope, $base) = ($1, $2);
48  
49 my $generate_selector = not exists $options->{reader};
50 my $generate_mutator = not exists $options->{writer};
51 if ($read_or_write_only) {
52 if ($read_or_write_only eq 'r') {
53 $read_private = $only_private;
54 $generate_mutator = $FALSE;
55 } else {
56 $write_private = $only_private;
57 $generate_selector = $FALSE;
58 } # end if
59 } # end if
60  
61 if ($generate_selector) {
62 my $read_scope = $read_private ? '_' : $scope;
63  
64 my $type = $options->{isa};
65 my $prefix;
66 if ( $type and ($type eq 'Bool' or $type eq 'Maybe[Bool]') ) {
67 $prefix = q<>;
68 } else {
69 $prefix = 'get_';
70 } # end if
71  
72 $options->{reader} = "$read_scope$prefix$base";
73 } # end if
74  
75 if ($generate_mutator) {
76 if ($write_private) {
77 $options->{writer} = "_set_$base";
78 } else {
79 $options->{writer} = "${scope}set_$base";
80 } # end if
81 } # end if
82  
83 delete $options->{is};
84 } # end if
85 } # end if
86  
87 return;
88 }; # end before _process_options()
89  
90  
91 no Moose::Role;
92  
93 1;
94  
95 __END__