line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Param::Compound; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
904
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
5
|
1
|
|
|
1
|
|
4
|
use base 'Class::Param::Base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
79
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use Params::Validate qw[]; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
583
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
0
|
0
|
|
0
|
1
|
|
my $class = ref $_[0] ? ref shift : shift; |
11
|
0
|
|
|
|
|
|
my $params = Params::Validate::validate_with( |
12
|
|
|
|
|
|
|
params => \@_, |
13
|
|
|
|
|
|
|
spec => [ |
14
|
|
|
|
|
|
|
( |
15
|
|
|
|
|
|
|
{ |
16
|
|
|
|
|
|
|
type => Params::Validate::OBJECT, |
17
|
|
|
|
|
|
|
isa => 'Class::Param::Base', |
18
|
|
|
|
|
|
|
optional => 0 |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
) x @_ |
21
|
|
|
|
|
|
|
], |
22
|
|
|
|
|
|
|
called => "$class\::new" |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
return bless( $params, $class ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub params { |
29
|
0
|
0
|
|
0
|
0
|
|
return wantarray ? @{ $_[0] } : [ @{ $_[0] } ]; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub get { |
33
|
0
|
|
|
0
|
1
|
|
my ( $self, $name ) = @_; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my @values = (); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
foreach my $param ( $self->params ) { |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
next unless $param->has($name); |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $value = $param->get($name); |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
if ( ref $value eq 'ARRAY' ) { |
44
|
0
|
|
|
|
|
|
push @values, @{ $value }; |
|
0
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
0
|
|
|
|
|
|
push @values, $value; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
|
return @values > 1 ? \@values : $values[0]; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub set { |
55
|
0
|
|
|
0
|
1
|
|
my ( $self, $name, $value ) = @_; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
foreach my $param ( $self->params ) { |
58
|
0
|
|
|
|
|
|
$param->set( $name => $value ); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
return 1; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub clear { |
65
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
foreach my $param ( $self->params ) { |
68
|
0
|
|
|
|
|
|
$param->clear; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return 1; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub remove { |
75
|
0
|
|
|
0
|
1
|
|
my ( $self, $name ) = @_; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my @removed = (); |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
foreach my $param ( $self->params ) { |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my $value = $param->remove($name); |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
if ( ref $value eq 'ARRAY' ) { |
84
|
0
|
|
|
|
|
|
push @removed, @{ $value }; |
|
0
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
else { |
87
|
0
|
|
|
|
|
|
push @removed, $value; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
|
return @removed > 1 ? \@removed : $removed[0]; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub names { |
95
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
my %seen = (); |
98
|
0
|
|
|
|
|
|
my @names = (); |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
foreach my $param ( $self->params ) { |
101
|
0
|
|
|
|
|
|
push @names, $param->names; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
return grep { $seen{$_}++ == 0 } @names; |
|
0
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__END__ |