Moose/Role/Attribute.pm

filter: Statementstmt 100% 5 / 5 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 100% 7 / 7 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Moose.pm ↑ Summary
1 # ##############################################################################
2 # # Script : Modern::PBP::Moose::Role::Attribute #
3 # # -------------------------------------------------------------------------- #
4 # # Copyright : Free under 'GNU General Public License' or 'Artistic License' #
5 # # Authors : JVBSOFT - Jürgen von Brietzke 0.001 - 1.200 #
6 # # Version : 1.200 14.Feb.2016 #
7 # # -------------------------------------------------------------------------- #
8 # # Function : Defines the attributes of getter and setter methods. #
9 # # -------------------------------------------------------------------------- #
10 # # Language : PERL 5 (V) 5.12.xx - 5.22.xx #
11 # # Coding : ISO 8859-15 / Latin-9 UNIX-lineendings #
12 # # Standards : Perl-Best-Practices severity 1 (brutal) #
13 # # -------------------------------------------------------------------------- #
14 # # Pragmas : none #
15 # # -------------------------------------------------------------------------- #
16 # # Module : Moose::Role ActivePerl-CORE-Module #
17 # # ------------------------------------------------------------- #
18 # # Modern::PBP::Perl ActivePerl-REPO-Module #
19 # ##############################################################################
20  
21 package Modern::PBP::Moose::Role::Attribute 1.200;
22  
23 # ##############################################################################
24  
25 3 ▶use 5.012;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 3 ▶use Modern::PBP::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 use Moose::Role;
29  
30 # ##############################################################################
31 # # Function | replaces getter / setter Method by 'get _... / set _...'. #
32 # # ----------+------------+-------------------------------------------------- #
33 # # Parameter | Object | Class-Name #
34 # # | Str | Name der getter/setter #
35 # # | Any | Options #
36 # # ----------+------------+-------------------------------------------------- #
37 # # Result | none #
38 # ##############################################################################
39  
40 before _process_options => sub {
41  
42 my ( $class, $name, $options ) = @ARG;
43  
44 # --- identify caller -------------------------------------------------------
45 my $caller = scalar caller 12;
46  
47 no strict qw{refs};
48 if ( defined ${ $caller . '::pbp' } ) {
49 use strict;
50  
51 # --- PBP callers required -----------------------------------------------
52 if ( exists $options->{is} and $options->{is} ne q{bare} ) {
53  
54 # --- 'is' parameter set and not equal to'bare' -----------------------
55 if ( not( exists $options->{reader} or exists $options->{writer} ) ) {
56  
57 # --- No specified getter/setter method ----------------------------
58 my ( $get, $set );
59 if ( $name =~ /^[_]/ismx ) {
60 ( $get, $set ) = ( q{_get}, q{_set} );
61 }
62 else {
63 ( $get, $set ) = ( q{get_}, q{set_} );
64 }
65 $options->{reader} = $get . $name;
66 if ( $options->{is} eq 'rw' ) {
67 $options->{writer} = $set . $name;
68 }
69 delete $options->{is};
70 }
71 }
72 }
73  
74 };
75  
76 # ##############################################################################
77  
78 no Moose::Role;
79  
80 # ##############################################################################
81 # # E N D #
82 # ##############################################################################
83 1;
84 __END__
« Moose.pm ↑ Summary