line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package EntityModel::Field; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$EntityModel::Field::VERSION = '0.102'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
use EntityModel::Class { |
6
|
18
|
|
|
|
|
374
|
'name' => { type => 'string' }, |
7
|
|
|
|
|
|
|
'default' => { type => 'string' }, |
8
|
|
|
|
|
|
|
'null' => { type => 'bool' }, |
9
|
|
|
|
|
|
|
'type' => { type => 'string' }, |
10
|
|
|
|
|
|
|
'length' => { type => 'int' }, |
11
|
|
|
|
|
|
|
'description' => { type => 'string' }, |
12
|
|
|
|
|
|
|
'precision' => { type => 'int' }, |
13
|
|
|
|
|
|
|
'scale' => { type => 'int' }, |
14
|
|
|
|
|
|
|
'unique' => { type => 'bool' }, |
15
|
|
|
|
|
|
|
'refer' => { type => 'EntityModel::Field::Refer' }, |
16
|
18
|
|
|
18
|
|
59629
|
}; |
|
18
|
|
|
|
|
87790
|
|
17
|
|
|
|
|
|
|
|
18
|
18
|
|
|
18
|
|
9804
|
use overload '""' => sub { 'field:' . shift->name }, fallback => 1; |
|
18
|
|
|
45
|
|
38
|
|
|
18
|
|
|
|
|
214
|
|
|
45
|
|
|
|
|
7964
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
EntityModel::Field - field definitions for L |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 VERSION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
version 0.102 |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SYNOPSIS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
See L. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 DESCRIPTION |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
See L. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
0
|
0
|
sub method { shift->name } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub create_from_definition { |
41
|
34
|
|
|
34
|
0
|
48
|
my $class = shift; |
42
|
34
|
|
|
|
|
40
|
my $def = shift; |
43
|
34
|
|
|
|
|
117
|
my $self = $class->new; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Should only have one of these but we treat all nested elements as arrays in our definitions. |
46
|
34
|
|
100
|
|
|
584
|
foreach my $refer_def (@{delete($def->{refer}) // []}) { |
|
34
|
|
|
|
|
190
|
|
47
|
3
|
|
|
|
|
15
|
my $refer = EntityModel::Field::Refer->new; |
48
|
3
|
|
|
|
|
54
|
$refer->$_($refer_def->{$_}) foreach keys %$refer_def; |
49
|
3
|
|
|
|
|
51
|
$self->refer($refer); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Use the accessors so that we die satisfactorily when provided with anything invalid. |
53
|
34
|
|
|
|
|
292
|
$self->$_($def->{$_}) foreach keys %$def; |
54
|
34
|
|
|
|
|
1104
|
return $self; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |