line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Object::Lazy::Validate; ## no critic (TidyCode)
|
2
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
65
|
use strict;
|
|
14
|
|
|
|
|
16
|
|
|
14
|
|
|
|
|
451
|
|
4
|
14
|
|
|
14
|
|
59
|
use warnings;
|
|
14
|
|
|
|
|
19
|
|
|
14
|
|
|
|
|
513
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.12';
|
7
|
|
|
|
|
|
|
|
8
|
14
|
|
|
14
|
|
7042
|
use Params::Validate qw(:all);
|
|
14
|
|
|
|
|
77670
|
|
|
14
|
|
|
|
|
4805
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub validate_new { ## no critic (ArgUnpacking)
|
11
|
17
|
|
|
17
|
1
|
597
|
return validate_with(
|
12
|
|
|
|
|
|
|
params => \@_,
|
13
|
|
|
|
|
|
|
spec => [
|
14
|
|
|
|
|
|
|
{type => SCALAR},
|
15
|
|
|
|
|
|
|
{type => CODEREF | HASHREF},
|
16
|
|
|
|
|
|
|
],
|
17
|
|
|
|
|
|
|
stack_skip => 1,
|
18
|
|
|
|
|
|
|
);
|
19
|
|
|
|
|
|
|
}
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# check and modify params
|
22
|
|
|
|
|
|
|
sub init {
|
23
|
17
|
|
|
17
|
1
|
31
|
my $params = shift;
|
24
|
|
|
|
|
|
|
|
25
|
17
|
100
|
|
|
|
69
|
if (ref $params eq 'CODE') {
|
26
|
7
|
|
|
|
|
20
|
$params = {
|
27
|
|
|
|
|
|
|
build => $params,
|
28
|
|
|
|
|
|
|
};
|
29
|
|
|
|
|
|
|
}
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
return validate_with(
|
32
|
|
|
|
|
|
|
params => $params,
|
33
|
|
|
|
|
|
|
spec => {
|
34
|
|
|
|
|
|
|
build => {type => CODEREF},
|
35
|
|
|
|
|
|
|
isa => {type => SCALAR | ARRAYREF, default => []},
|
36
|
|
|
|
|
|
|
DOES => {type => SCALAR | ARRAYREF, default => []},
|
37
|
|
|
|
|
|
|
VERSION => {type => SCALAR | OBJECT, optional => 1},
|
38
|
|
|
|
|
|
|
version_from => {type => SCALAR, optional => 1},
|
39
|
|
|
|
|
|
|
logger => {type => CODEREF, optional => 1},
|
40
|
|
|
|
|
|
|
ref => {
|
41
|
|
|
|
|
|
|
type => SCALAR,
|
42
|
|
|
|
|
|
|
optional => 1,
|
43
|
|
|
|
|
|
|
callbacks => {
|
44
|
|
|
|
|
|
|
'depends use Object::Lazy::Ref' => sub {
|
45
|
2
|
|
|
2
|
|
43
|
$Object::Lazy::Ref::VERSION;
|
46
|
|
|
|
|
|
|
}
|
47
|
|
|
|
|
|
|
}
|
48
|
|
|
|
|
|
|
},
|
49
|
|
|
|
|
|
|
},
|
50
|
17
|
|
|
|
|
617
|
called => 'the 2nd parameter hashref',
|
51
|
|
|
|
|
|
|
);
|
52
|
|
|
|
|
|
|
};
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# $Id$
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1;
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__
|