blob: e586dec40f50650b527d87f18ca8c7fecdbcf9c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package Data::MultiValued::UglySerializationHelperRole; use Moose::Role; sub new_in_place { my ($class,$hash) = @_; my $self = bless $hash,$class; for my $attr ($class->meta->get_all_attributes) { if ($attr->does('Data::MultiValued::AttributeTrait')) { $attr->_rebless_slot($self); } } return $self; } sub as_hash { my ($self) = @_; my %ret = %$self; for my $attr ($self->meta->get_all_attributes) { if ($attr->does('Data::MultiValued::AttributeTrait')) { my $st = $attr->_as_hash($self); if ($st) { $ret{$attr->full_storage_slot} = $st; } else { delete $ret{$attr->full_storage_slot}; } } } return \%ret; } 1;
|