blib/lib/MOP4Import/FieldSpec.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 50 CC 2 SCAR 10.0
CC
2
Cov
0%
clone
6.0
FieldSpec
2.0
BEGIN
2.0
CRAP 2.7
1 package MOP4Import::FieldSpec; sub FieldSpec () {__PACKAGE__}
2 use strict;
3 use warnings qw(FATAL all NONFATAL misc);
4 use Carp;
5 use Exporter qw/import/;
6  
7 require MOP4Import::Util; # Delay loading
8  
9 BEGIN {
10 our @EXPORT_OK = qw/FieldSpec/;
11 our @EXPORT = @EXPORT_OK;
12 }
13  
14 use fields
15 ('name'
16 , 'doc' # documentation
17 , 'default'
18 , 'no_getter'
19 , 'package'
20 , 'json_type'
21 , 'isa'
22 , 'validator'
23 , 'zsh_completer'
24 , 'extra'
25 # file? line? package?
26 );
27  
28 sub new {
29 my FieldSpec $self = fields::new(shift);
30 %$self = @_;
31 $self;
32 }
33  
34 sub clone {
35 (my FieldSpec $self) = @_;
36 my FieldSpec $clone = fields::new(ref $self);
37 foreach my $key (keys %$self) {
38 my $val = $self->{$key};
39 $clone->{$key} = do {
40 if (ref $val eq 'CODE') {
41 $val
42 } else {
43 MOP4Import::Util::shallow_copy($val);
44 }
45 };
46 }
47 $clone;
48 }
49  
50 1;