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