line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ODS::Table::Row; |
2
|
|
|
|
|
|
|
|
3
|
72
|
|
|
72
|
|
1275
|
use YAOO; |
|
72
|
|
|
|
|
135
|
|
|
72
|
|
|
|
|
427
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use overload |
6
|
157951
|
100
|
|
157951
|
|
2612610
|
'%{}' => sub { caller() =~ m/YAOO$/ ? $_[0] : $_[0]->as_hash; }, |
7
|
72
|
|
|
72
|
|
34265
|
fallback => 1; |
|
72
|
|
|
|
|
205
|
|
|
72
|
|
|
|
|
1664
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has table => isa(object); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has columns => isa(ordered_hash), default(1); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has __file => isa(string); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has __custom_file_name => isa(string); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub build { |
18
|
2666
|
|
|
2666
|
0
|
53309
|
my ($self, %args) = @_; |
19
|
|
|
|
|
|
|
|
20
|
2666
|
|
|
|
|
12252
|
$self->table($args{table}); |
21
|
|
|
|
|
|
|
|
22
|
2666
|
100
|
|
|
|
10059
|
if (ref $args{data} eq 'ARRAY') { |
23
|
3
|
|
|
|
|
6
|
my $column = 'array_items'; |
24
|
3
|
|
|
|
|
3
|
my $value = [ map { $self->table->parent_column->object_class->instantiate($self->table->parent_column, 0, $_) } @{ $args{data} } ]; |
|
6
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
16
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $col = $self->table->columns->{$column}->build_column( |
27
|
|
|
|
|
|
|
$value, $args{inflated}, $args{serialize_class} |
28
|
3
|
|
|
|
|
9
|
); |
29
|
3
|
|
|
|
|
13
|
$self->columns->{$column} = $col; |
30
|
3
|
|
|
|
|
93
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
2663
|
|
|
|
|
11704
|
$self->__custom_file_name(delete $args{data}{__custom_file_name}); |
34
|
2663
|
|
|
|
|
13155
|
$self->__file(delete $args{data}{__file}); |
35
|
|
|
|
|
|
|
|
36
|
2663
|
|
|
|
|
5436
|
for my $column ( keys %{ $self->table->columns } ) { |
|
2663
|
|
|
|
|
7251
|
|
37
|
|
|
|
|
|
|
my $col = $self->table->columns->{$column}->build_column( |
38
|
|
|
|
|
|
|
$args{data}{$column}, $args{inflated}, $args{serialize_class} |
39
|
39420
|
|
|
|
|
272515
|
); |
40
|
39420
|
|
|
|
|
94723
|
$self->columns->{$column} = $col; |
41
|
|
|
|
|
|
|
YAOO::make_keyword($self->table->row_class, $column, sub { |
42
|
163
|
|
|
163
|
|
43951
|
my $self = shift; |
43
|
163
|
|
|
|
|
327
|
$self->columns->{$column}->value(@_); |
44
|
39420
|
100
|
|
|
|
542383
|
}) unless $self->can($column); |
45
|
|
|
|
|
|
|
} |
46
|
2663
|
|
|
|
|
35340
|
return $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub as_hash { |
50
|
174
|
|
|
174
|
0
|
292
|
my %hash; |
51
|
|
|
|
|
|
|
$hash{$_} = $_[0]->columns->{$_}->value |
52
|
174
|
|
|
|
|
184
|
for keys %{$_[0]->columns}; |
|
174
|
|
|
|
|
490
|
|
53
|
174
|
|
|
|
|
2772
|
return \%hash; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub set_row { |
57
|
7
|
|
|
7
|
0
|
15
|
my ($self, $data) = @_; |
58
|
7
|
|
|
|
|
11
|
for my $key ( keys %{ $data } ) { |
|
7
|
|
|
|
|
31
|
|
59
|
4
|
|
|
|
|
11
|
$self->$key($data->{$key}); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub store_row { |
64
|
1774
|
|
|
1774
|
0
|
5579
|
my ($self, $data) = @_; |
65
|
1774
|
50
|
0
|
|
|
6063
|
$self->set_row($data) if defined $data && ref($data || "") eq "HASH"; |
|
|
|
33
|
|
|
|
|
66
|
|
|
|
|
|
|
my %hash = map +( |
67
|
|
|
|
|
|
|
$_ => $self->columns->{$_}->store_column()->value |
68
|
1774
|
|
|
|
|
4088
|
), keys %{ $self->columns }; |
|
1774
|
|
|
|
|
5325
|
|
69
|
1774
|
|
|
|
|
90993
|
return \%hash; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub validate { |
73
|
1723
|
|
|
1723
|
0
|
4628
|
my ($self, $data) = @_; |
74
|
1723
|
100
|
50
|
|
|
7973
|
$self->set_row($data) if defined $data && ref($data || "") eq "HASH"; |
|
|
|
66
|
|
|
|
|
75
|
|
|
|
|
|
|
my %hash = map +( |
76
|
|
|
|
|
|
|
$_ => $self->columns->{$_}->validate()->value |
77
|
1723
|
|
|
|
|
4457
|
), keys %{ $self->columns }; |
|
1723
|
|
|
|
|
5041
|
|
78
|
1723
|
|
|
|
|
62459
|
return \%hash; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub update { |
82
|
5
|
100
|
|
5
|
0
|
3006
|
my ($self, $update) = (shift, @_ > 1 ? { @_ } : $_[0]); |
83
|
5
|
|
|
|
|
25
|
$self->set_row($update); |
84
|
5
|
|
|
|
|
79
|
$self->table->storage->update_row($self); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub delete { |
88
|
2
|
|
|
2
|
0
|
1003
|
my ($self) = @_; |
89
|
2
|
|
|
|
|
9
|
$self->table->storage->delete_row($self); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |