line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Param::Callback; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
3214
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
81
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
5
|
2
|
|
|
2
|
|
12
|
use base 'Class::Param::Base'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
851
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
1160
|
use Params::Validate qw[]; |
|
2
|
|
|
|
|
13228
|
|
|
2
|
|
|
|
|
153
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
6
|
my @required = qw[ get set names remove ]; |
12
|
2
|
|
|
|
|
7
|
my @optional = qw[ add clear count has param scan as_hash ]; |
13
|
2
|
|
|
|
|
4
|
my $spec = { }; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
|
|
6
|
foreach my $method ( @required, @optional ) { |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
15
|
no strict 'refs'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
487
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
*$method = sub { |
20
|
132
|
|
|
132
|
|
38773
|
my $self = shift; |
21
|
132
|
|
66
|
|
|
1052
|
my $code = $self->{$method} || Class::Param::Base->can($method); |
22
|
132
|
|
|
|
|
512
|
return $self->$code(@_); |
23
|
22
|
|
|
|
|
147
|
}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
5
|
foreach my $required ( @required ) { |
27
|
|
|
|
|
|
|
|
28
|
8
|
|
|
|
|
27
|
$spec->{ $required } = { |
29
|
|
|
|
|
|
|
type => Params::Validate::CODEREF, |
30
|
|
|
|
|
|
|
optional => 0 |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
|
|
5
|
foreach my $optional ( @optional ) { |
35
|
|
|
|
|
|
|
|
36
|
14
|
|
|
|
|
38
|
$spec->{ $optional } = { |
37
|
|
|
|
|
|
|
type => Params::Validate::CODEREF, |
38
|
|
|
|
|
|
|
optional => 1 |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
*new = sub { |
43
|
1
|
50
|
|
1
|
|
6065
|
my $class = ref $_[0] ? ref shift : shift; |
44
|
1
|
|
|
|
|
80
|
my $self = Params::Validate::validate_with( |
45
|
|
|
|
|
|
|
params => \@_, |
46
|
|
|
|
|
|
|
spec => $spec, |
47
|
|
|
|
|
|
|
called => "$class\::new" |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
13
|
return bless( $self, $class ); |
51
|
2
|
|
|
|
|
64
|
}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |