Fix that failing test, caused by $self->collapse_attribute_value() || return
[gitmo/MooseX-Storage.git] / lib / MooseX / Storage / Engine.pm
index a90c3ea..9b39d15 100644 (file)
@@ -2,7 +2,8 @@
 package MooseX::Storage::Engine;
 use Moose;
 
-our $VERSION = '0.02';
+our $VERSION   = '0.02';
+our $AUTHORITY = 'cpan:STEVAN';
 
 # the class marker when 
 # serializing an object. 
@@ -55,12 +56,15 @@ sub expand_object {
 
 sub collapse_attribute {
     my ($self, $attr, $options)  = @_;
-    $self->storage->{$attr->name} = $self->collapse_attribute_value($attr, $options) || return;
+    my $value = $self->collapse_attribute_value($attr, $options);
+    return if !defined($value);
+    $self->storage->{$attr->name} = $value;
 }
 
 sub expand_attribute {
     my ($self, $attr, $data, $options)  = @_;
-    $self->storage->{$attr->name} = $self->expand_attribute_value($attr, $data->{$attr->name}, $options) || return;
+    my $value = $self->expand_attribute_value($attr, $data->{$attr->name}, $options);
+    $self->storage->{$attr->name} = defined $value ? $value : return;
 }
 
 sub collapse_attribute_value {
@@ -203,6 +207,7 @@ my %TYPES = (
     'Int'      => { expand => sub { shift }, collapse => sub { shift } },
     'Num'      => { expand => sub { shift }, collapse => sub { shift } },
     'Str'      => { expand => sub { shift }, collapse => sub { shift } },
+    'Bool'     => { expand => sub { shift }, collapse => sub { shift } },
     # These are the trickier ones, (see notes)
     # NOTE:
     # Because we are nice guys, we will check