2 package MooseX::Storage::Format::Storable;
8 our $AUTHORITY = 'cpan:STEVAN';
14 my ( $class, $stored, @args ) = @_;
15 $class->unpack( Storable::thaw($stored), @args );
19 my ( $self, @args ) = @_;
20 Storable::nfreeze( $self->pack(@args) );
31 MooseX::Storage::Format::Storable - A Storable serialization role
39 with Storage('format' => 'Storable');
41 has 'x' => (is => 'rw', isa => 'Int');
42 has 'y' => (is => 'rw', isa => 'Int');
46 my $p = Point->new(x => 10, y => 10);
48 ## methods to freeze/thaw into
49 ## a specified serialization format
51 # pack the class with Storable
52 my $storable_data = $p->freeze();
54 # unpack the storable data into the class
55 my $p2 = Point->thaw($storable_data);
59 This module will C<thaw> and C<freeze> Moose classes using Storable. It
60 uses C<Storable::nfreeze> by default so that it can be easily used
61 in IPC scenarios across machines or just locally.
63 One important thing to note is that this module does not mix well
64 with the IO modules. The structures that C<freeze> and C<thaw> deal with
65 are Storable's memory representation, and (as far as I know) that
66 is not easily just written onto a file. If you want file based
67 serialization with Storable, the please look at the
68 L<MooseX::Storage::IO::StorableFile> role instead.
76 =item B<thaw ($stored)>
90 All complex software has bugs lurking in it, and this module is no
91 exception. If you find a bug please either email me, or add the bug
96 Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
98 =head1 COPYRIGHT AND LICENSE
100 Copyright 2007-2008 by Infinity Interactive, Inc.
102 L<http://www.iinteractive.com>
104 This library is free software; you can redistribute it and/or modify
105 it under the same terms as Perl itself.