Version 0.31
[gitmo/MooseX-Storage.git] / lib / MooseX / Storage / Engine.pm
index cee4178..8a7c1e7 100644 (file)
@@ -3,7 +3,7 @@ package MooseX::Storage::Engine;
 use Moose;
 use Scalar::Util qw(refaddr);
 
-our $VERSION   = '0.25';
+our $VERSION   = '0.31';
 our $AUTHORITY = 'cpan:STEVAN';
 
 # the class marker when
@@ -22,7 +22,7 @@ has 'seen' => (
     default => sub {{}}
 );
 
-has 'object' => (is => 'rw', isa => 'Object');
+has 'object' => (is => 'rw', isa => 'Object', predicate => '_has_object');
 has 'class'  => (is => 'rw', isa => 'Str');
 
 ## this is the API used by other modules ...
@@ -143,7 +143,7 @@ sub map_attributes {
     } grep {
         # Skip our special skip attribute :)
         !$_->does('MooseX::Storage::Meta::Attribute::Trait::DoNotSerialize')
-    } ($self->object || $self->class)->meta->get_all_attributes;
+    } ($self->_has_object ? $self->object : $self->class)->meta->get_all_attributes;
 }
 
 ## ------------------------------------------------------------------
@@ -374,7 +374,17 @@ MooseX::Storage::Engine - The meta-engine to handle collapsing and expanding obj
 
 =head1 DESCRIPTION
 
-No user serviceable parts inside. If you really want to know, read the source :)
+There really aren't any major user serviceable parts here. However the typical
+use case is adding new non-Moose classes to the type registry for
+serialization. Here is an example of this for DateTime objects. This
+assumes a C<DateTime> type has been registered.
+
+    MooseX::Storage::Engine->add_custom_type_handler(
+        'DateTime' => (
+            expand   => sub { DateTime->new(shift) },
+            collapse => sub { (shift)->iso8601 },
+        )
+    );
 
 =head1 METHODS