line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ODS::Table::Row; |
2
|
|
|
|
|
|
|
|
3
|
72
|
|
|
72
|
|
434
|
use YAOO; |
|
72
|
|
|
|
|
149
|
|
|
72
|
|
|
|
|
355
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use overload |
6
|
157435
|
100
|
|
157435
|
|
2444839
|
'%{}' => sub { caller() =~ m/YAOO$/ ? $_[0] : $_[0]->as_hash; }, |
7
|
72
|
|
|
72
|
|
29552
|
fallback => 1; |
|
72
|
|
|
|
|
89
|
|
|
72
|
|
|
|
|
1406
|
|
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
|
2648
|
|
|
2648
|
0
|
52037
|
my ($self, %args) = @_; |
19
|
|
|
|
|
|
|
|
20
|
2648
|
|
|
|
|
12282
|
$self->table($args{table}); |
21
|
2648
|
|
|
|
|
11786
|
$self->__custom_file_name(delete $args{data}{__custom_file_name}); |
22
|
2648
|
|
|
|
|
11120
|
$self->__file(delete $args{data}{__file}); |
23
|
|
|
|
|
|
|
|
24
|
2648
|
|
|
|
|
6006
|
for my $column ( keys %{ $self->table->columns } ) { |
|
2648
|
|
|
|
|
6108
|
|
25
|
|
|
|
|
|
|
my $col = $self->table->columns->{$column}->build_column( |
26
|
|
|
|
|
|
|
$args{data}{$column}, $args{inflated}, $args{serialize_class} |
27
|
39374
|
|
|
|
|
252919
|
); |
28
|
39374
|
|
|
|
|
93449
|
$self->columns->{$column} = $col; |
29
|
|
|
|
|
|
|
YAOO::make_keyword($self->table->row_class, $column, sub { |
30
|
161
|
|
|
161
|
|
52004
|
my $self = shift; |
31
|
161
|
|
|
|
|
357
|
$self->columns->{$column}->value(@_); |
32
|
39374
|
100
|
|
|
|
528763
|
}) unless $self->can($column); |
33
|
|
|
|
|
|
|
} |
34
|
2648
|
|
|
|
|
34550
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub as_hash { |
38
|
132
|
|
|
132
|
0
|
183
|
my %hash; |
39
|
|
|
|
|
|
|
$hash{$_} = $_[0]->columns->{$_}->value |
40
|
132
|
|
|
|
|
158
|
for keys %{$_[0]->columns}; |
|
132
|
|
|
|
|
15660
|
|
41
|
132
|
|
|
|
|
2366
|
return \%hash; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub set_row { |
45
|
6
|
|
|
6
|
0
|
14
|
my ($self, $data) = @_; |
46
|
6
|
|
|
|
|
12
|
for my $key ( keys %{ $data } ) { |
|
6
|
|
|
|
|
20
|
|
47
|
4
|
|
|
|
|
15
|
$self->$key($data->{$key}); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub store_row { |
52
|
1760
|
|
|
1760
|
0
|
4916
|
my ($self, $data) = @_; |
53
|
1760
|
50
|
0
|
|
|
7318
|
$self->set_row($data) if defined $data && ref($data || "") eq "HASH"; |
|
|
|
33
|
|
|
|
|
54
|
|
|
|
|
|
|
my %hash = map +( |
55
|
|
|
|
|
|
|
$_ => $self->columns->{$_}->store_column()->value |
56
|
1760
|
|
|
|
|
3187
|
), keys %{ $self->columns }; |
|
1760
|
|
|
|
|
4092
|
|
57
|
1760
|
|
|
|
|
65057
|
return \%hash; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub validate { |
61
|
1720
|
|
|
1720
|
0
|
4979
|
my ($self, $data) = @_; |
62
|
1720
|
100
|
50
|
|
|
10337
|
$self->set_row($data) if defined $data && ref($data || "") eq "HASH"; |
|
|
|
66
|
|
|
|
|
63
|
|
|
|
|
|
|
my %hash = map +( |
64
|
|
|
|
|
|
|
$_ => $self->columns->{$_}->validate()->value |
65
|
1720
|
|
|
|
|
4396
|
), keys %{ $self->columns }; |
|
1720
|
|
|
|
|
4272
|
|
66
|
1720
|
|
|
|
|
42737
|
return \%hash; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub update { |
70
|
4
|
100
|
|
4
|
0
|
1861
|
my ($self, $update) = (shift, @_ > 1 ? { @_ } : $_[0]); |
71
|
4
|
|
|
|
|
19
|
$self->set_row($update); |
72
|
4
|
|
|
|
|
92
|
$self->table->storage->update_row($self); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub delete { |
76
|
2
|
|
|
2
|
0
|
978
|
my ($self) = @_; |
77
|
2
|
|
|
|
|
11
|
$self->table->storage->delete_row($self); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |