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