blib/lib/FindApp/Object/State/Group/Class.pm untested

filter: Statementstmt 0.0% 0 / 67 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 9 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 23 Podpod 0.0% 0 / 15 totaltotal 0.0% 0 / 116 CC 2 SCAR 8.8
CC
2
Cov
0%
object
6.0
dir_types
2.0
dir_field
2.0
CRAP 2.4
1 package FindApp::Object::State::Group::Class;
2  
3 use v5.10;
4 use strict;
5 use warnings;
6 use mro "c3";
7  
8 use FindApp::Vars qw(:all);
9 use FindApp::Utils qw(:all);
10  
11 sibuse "State::Dirs";
12  
13 #################################################################
14  
15 sub dir_field ( _ ) ;
16 sub dir_fields ( ) ;
17 sub dir_types ( ) ;
18 sub field_map ( & @ ) ;
19 sub type_map ( & @ ) ;
20  
21 #################################################################
22  
23 sub dir_types() {
24 return qw(allowed wanted found);
25 }
26  
27 sub dir_field(_) {
28 my($type) = @_;
29 no strict "refs";
30 return sibpackage("State::\U$type")->();
31 }
32  
33 sub type_map(&@) {
34 my $code = shift;
35 return map { &$code } +dir_types, @_;
36 }
37  
38 sub dir_fields() {
39 my $fields = [ type_map{dir_field} ];
40 return @$fields;
41 }
42  
43 sub field_map(&@) {
44 my $code = shift;
45 return map { &$code } +dir_fields, @_;
46 }
47  
48 use namespace::clean;
49  
50 sub class { &ENTER_TRACE_2;
51 my($self) = @_;
52 return blessed($self) || $self;
53 }
54  
55 sub object { &ENTER_TRACE_2;
56 my($self) = @_;
57 croak "not an object" unless blessed $self;
58 return $self;
59 }
60  
61 sub new { &ENTER_TRACE_2;
62 good_args(@_ >= 2);
63 my($invocant, $name) = (shift, shift);
64 my $class = blessed($invocant) || $invocant;
65 my %dirlists = field_map { $_ => sibpackage("State::Dirs")->new };
66 return bless(\%dirlists, $class)->params(
67 name => [$name],
68 unexported => [1],
69 @_,
70 );
71 }
72  
73 sub copy { &ENTER_TRACE_2;
74 good_args(@_ == 2);
75 my($new, $old) = @_;
76 my $name = $old->name;
77 $new->name eq $old->name || panic "name mismatch";
78 $new->exported($old->exported);
79 for my $field (dir_types()) {
80 $new->$field->copy($old->$field->object);
81 }
82 }
83  
84 sub params { &ENTER_TRACE_2;
85 my($self, %inits) = @_;
86 while (my($method, $aref) = each %inits) {
87 $self->$method(@$aref);
88 }
89 return $self;
90 }
91  
92 1;
93  
94 =encoding utf8
95  
96 =head1 NAME
97  
98 FindApp::Object::State::Group::Object::Class - FIXME
99  
100 =head1 SYNOPSIS
101  
102 use FindApp::Object::State::Group::Object::Class;
103  
104 =head1 DESCRIPTION
105  
106 =head2 Public Methods
107  
108 =over
109  
110 =item class
111  
112 =item copy
113  
114 =item new
115  
116 =item object
117  
118 =item params
119  
120 =back
121  
122 =head2 Exports
123  
124 =over
125  
126 =item FIXME
127  
128 =back
129  
130 =head1 EXAMPLES
131  
132 =head1 ENVIRONMENT
133  
134 =head1 SEE ALSO
135  
136 =over
137  
138 =item L<FindApp>
139  
140 =back
141  
142 =head1 CAVEATS AND PROVISOS
143  
144 =head1 BUGS AND LIMITATIONS
145  
146 =head1 HISTORY
147  
148 =head1 AUTHOR
149  
150 Tom Christiansen << <tchrist@perl.com> >>
151  
152 =head1 LICENCE AND COPYRIGHT
153  
154 Copyright (c) 2016, Tom Christiansen C<< <tchrist@perl.com> >>.
155 All Rights Reserved.
156  
157 This module is free software; you can redistribute it and/or
158 modify it under the same terms as Perl itself. See L<perlartistic>.
159  
160 =cut
161