line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Mixin Object for Validation::Class Classes |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Validation::Class::Mixin provides functions for processing for mixin objects |
4
|
|
|
|
|
|
|
# and provides accessors for mixin directives. This class is derived from the |
5
|
|
|
|
|
|
|
# L class. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Validation::Class::Mixin; |
8
|
|
|
|
|
|
|
|
9
|
108
|
|
|
108
|
|
649
|
use strict; |
|
108
|
|
|
|
|
206
|
|
|
108
|
|
|
|
|
2711
|
|
10
|
108
|
|
|
108
|
|
552
|
use warnings; |
|
108
|
|
|
|
|
203
|
|
|
108
|
|
|
|
|
2629
|
|
11
|
|
|
|
|
|
|
|
12
|
108
|
|
|
108
|
|
564
|
use Validation::Class::Directives; |
|
108
|
|
|
|
|
277
|
|
|
108
|
|
|
|
|
2479
|
|
13
|
108
|
|
|
108
|
|
567
|
use Validation::Class::Errors; |
|
108
|
|
|
|
|
215
|
|
|
108
|
|
|
|
|
2600
|
|
14
|
|
|
|
|
|
|
|
15
|
108
|
|
|
108
|
|
546
|
use Validation::Class::Util '!has'; |
|
108
|
|
|
|
|
234
|
|
|
108
|
|
|
|
|
749
|
|
16
|
108
|
|
|
108
|
|
558
|
use Carp 'confess'; |
|
108
|
|
|
|
|
209
|
|
|
108
|
|
|
|
|
7016
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '7.900057'; # VERSION |
19
|
|
|
|
|
|
|
|
20
|
108
|
|
|
108
|
|
592
|
use base 'Validation::Class::Mapping'; |
|
108
|
|
|
|
|
227
|
|
|
108
|
|
|
|
|
33438
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $directives = Validation::Class::Directives->new; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
foreach my $directive ($directives->values) { |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# create accessors from default configuration (once) |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
if ($directive->mixin) { |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $name = $directive->name; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
next if __PACKAGE__->can($name); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# errors object |
35
|
|
|
|
|
|
|
if ($name eq 'errors') { |
36
|
|
|
|
|
|
|
my %spec = |
37
|
|
|
|
|
|
|
($name => sub { Validation::Class::Errors->new }); |
38
|
|
|
|
|
|
|
Validation::Class::Util::has(%spec); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# everything else |
42
|
|
|
|
|
|
|
else { |
43
|
|
|
|
|
|
|
my %spec = |
44
|
|
|
|
|
|
|
($name => sub { undef }); |
45
|
|
|
|
|
|
|
Validation::Class::Util::has(%spec); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub new { |
53
|
|
|
|
|
|
|
|
54
|
472
|
|
|
472
|
1
|
814
|
my $class = shift; |
55
|
|
|
|
|
|
|
|
56
|
472
|
|
|
|
|
1733
|
my $config = $class->build_args(@_); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
confess "Can't create a new mixin object without a name attribute" |
59
|
|
|
|
|
|
|
unless $config->{name} |
60
|
472
|
50
|
|
|
|
1496
|
; |
61
|
|
|
|
|
|
|
|
62
|
472
|
|
|
|
|
1019
|
my $self = bless {}, $class; |
63
|
|
|
|
|
|
|
|
64
|
472
|
|
|
|
|
2063
|
$self->add($config); |
65
|
|
|
|
|
|
|
|
66
|
472
|
|
|
|
|
2804
|
return $self; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |