line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ODS::Table::Column::ArrayObject; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use YAOO; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'ODS::Table::Column::Base'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
334
|
use ODS::Utils qw/clone error deep_unblessed reftype/; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
8
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has reference => isa(boolean); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has blessed => isa(boolean), default => 0; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has min_length => isa(integer); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has max_length => isa(integer); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has object_class => isa(string); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has serialize_class => isa(object); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub validation { |
22
|
5
|
|
|
5
|
0
|
66
|
my ($self, $value) = @_; |
23
|
|
|
|
|
|
|
|
24
|
5
|
100
|
50
|
|
|
34
|
if (ref($value || "SCALAR") =~ m/ARRAY/) { |
25
|
3
|
|
|
|
|
11
|
$value = $self->inflation($value); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
5
|
|
|
|
|
15
|
my $internal = $value->columns->{array_items}->value(); |
29
|
|
|
|
|
|
|
|
30
|
5
|
50
|
50
|
|
|
69
|
if ((reftype($internal) || "") ne 'ARRAY') { |
31
|
0
|
|
|
|
|
0
|
croak sprintf "The value passed to the %s column does not match the array object constraint.", |
32
|
|
|
|
|
|
|
$self->name; |
33
|
|
|
|
|
|
|
} |
34
|
5
|
50
|
33
|
|
|
14
|
if ($self->min_length && $self->min_length > scalar @{$internal}) { |
|
0
|
|
|
|
|
0
|
|
35
|
0
|
|
|
|
|
0
|
croak sprintf "The % column array length is less than the minimum allowed length for the attribute.", |
36
|
|
|
|
|
|
|
$self->name; |
37
|
|
|
|
|
|
|
} |
38
|
5
|
50
|
33
|
|
|
62
|
if ($self->max_length && $self->max_length < scalar @{$internal}) { |
|
0
|
|
|
|
|
0
|
|
39
|
0
|
|
|
|
|
0
|
croak sprintf "The % column array length is greater than the maximum allowed length for the attribute.", |
40
|
|
|
|
|
|
|
$self->name; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
5
|
|
|
|
|
63
|
return $value; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub inflation { |
47
|
3
|
|
|
3
|
0
|
8
|
my ($self, $value) = @_; |
48
|
|
|
|
|
|
|
|
49
|
3
|
50
|
|
|
|
23
|
if (! ref $value) { |
50
|
0
|
|
|
|
|
0
|
$value = $self->serialize_class->parse($value); |
51
|
0
|
|
|
|
|
0
|
$self->reference(1); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
3
|
50
|
|
|
|
15
|
return ref($value) =~ m/ARRAY/ ? do { |
55
|
3
|
|
|
|
|
16
|
$self->blessed(1); |
56
|
3
|
|
|
|
|
121
|
$value = $self->object_class->instantiate($self, 0, $value); |
57
|
3
|
|
|
|
|
14
|
$value; |
58
|
|
|
|
|
|
|
} : $value; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub deflation { |
62
|
3
|
|
|
3
|
0
|
31
|
my ($self, $value) = @_; |
63
|
|
|
|
|
|
|
|
64
|
3
|
50
|
50
|
|
|
17
|
if (reftype($value || "") eq 'HASH' && $self->blessed) { |
|
|
|
33
|
|
|
|
|
65
|
3
|
|
|
|
|
37
|
$value = $value->columns->{array_items}->value(); |
66
|
3
|
|
|
|
|
36
|
$value = [ map { $_->store_row() } @{ $value } ]; |
|
6
|
|
|
|
|
48
|
|
|
3
|
|
|
|
|
16
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
3
|
50
|
33
|
|
|
12
|
if ($self->reference && ref $value) { |
70
|
0
|
|
|
|
|
0
|
$value = $self->serialize_class->stringify($value); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
3
|
|
|
|
|
34
|
return $value; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |