package Data::MultiValued::UglySerializationHelperRole; BEGIN { $Data::MultiValued::UglySerializationHelperRole::VERSION = '0.0.1'; } BEGIN { $Data::MultiValued::UglySerializationHelperRole::DIST = 'Data-MultiValued'; } 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; __END__ =pod =head1 NAME Data::MultiValued::UglySerializationHelperRole =head1 VERSION version 0.0.1 =head1 AUTHOR Gianni Ceccarelli =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Net-a-porter.com. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut