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
|
109
|
|
|
109
|
|
761
|
use strict; |
|
109
|
|
|
|
|
281
|
|
|
109
|
|
|
|
|
3308
|
|
10
|
109
|
|
|
109
|
|
597
|
use warnings; |
|
109
|
|
|
|
|
255
|
|
|
109
|
|
|
|
|
2791
|
|
11
|
|
|
|
|
|
|
|
12
|
109
|
|
|
109
|
|
609
|
use Validation::Class::Directives; |
|
109
|
|
|
|
|
252
|
|
|
109
|
|
|
|
|
2194
|
|
13
|
109
|
|
|
109
|
|
622
|
use Validation::Class::Errors; |
|
109
|
|
|
|
|
237
|
|
|
109
|
|
|
|
|
2422
|
|
14
|
|
|
|
|
|
|
|
15
|
109
|
|
|
109
|
|
588
|
use Validation::Class::Util '!has'; |
|
109
|
|
|
|
|
294
|
|
|
109
|
|
|
|
|
787
|
|
16
|
109
|
|
|
109
|
|
711
|
use Carp 'confess'; |
|
109
|
|
|
|
|
256
|
|
|
109
|
|
|
|
|
7418
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '7.900059'; # VERSION |
19
|
|
|
|
|
|
|
|
20
|
109
|
|
|
109
|
|
746
|
use base 'Validation::Class::Mapping'; |
|
109
|
|
|
|
|
248
|
|
|
109
|
|
|
|
|
38642
|
|
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
|
478
|
|
|
478
|
1
|
978
|
my $class = shift; |
55
|
|
|
|
|
|
|
|
56
|
478
|
|
|
|
|
1462
|
my $config = $class->build_args(@_); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
confess "Can't create a new mixin object without a name attribute" |
59
|
|
|
|
|
|
|
unless $config->{name} |
60
|
478
|
50
|
|
|
|
1497
|
; |
61
|
|
|
|
|
|
|
|
62
|
478
|
|
|
|
|
1076
|
my $self = bless {}, $class; |
63
|
|
|
|
|
|
|
|
64
|
478
|
|
|
|
|
2063
|
$self->add($config); |
65
|
|
|
|
|
|
|
|
66
|
478
|
|
|
|
|
3136
|
return $self; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |