moose / MooseX-Storage

A serialization framework for Moose classes
http://metacpan.org/release/MooseX-Storage/
Other
6 stars 11 forks source link

Unable to serialize attributes with value of undef #9

Closed mcmillhj closed 9 years ago

mcmillhj commented 9 years ago

I am not sure whether this is expected behavior, but MooseX::Storage seems to be unable to serialize attributes with a value of undef. Example:

package MyObj; 
use Moose; 
use MooseX::Storage;
with Storage();

has [qw(a b)] => ( 
   is            => 'ro', 
   required => 1 
);

__PACKAGE__->meta->make_immutable;

package main;
use strict; 
use warnings; 
use Data::Dumper;

my $obj = MyObj->new( a => undef, b => '2' )->pack;
print Dumper $obj;
__END__
$VAR1 = {
          '__CLASS__' => 'MyObj',
          'b' => '2'
        };

If this is expected behavior then that's fine, I can easily use a different default value. If not, I am happy to look into the issue and submit a patch.

mcmillhj commented 9 years ago

looking back in the commit history and commit e5170b02c19d97893e0cb9282b07c1aa670bd752 handles this exact case. Our sysadmin said he installed the latest version of MooseX::Storage so I took that to mean 0.48; what he really meant to was the latest version packaged for Gentoo which is 0.33. My mistake.