2 package MooseX::Storage::Basic;
5 use MooseX::Storage::Engine;
8 our $AUTHORITY = 'cpan:STEVAN';
11 my ( $self, @args ) = @_;
12 my $e = MooseX::Storage::Engine->new( object => $self );
13 $e->collapse_object(@args);
17 my ( $class, $data, @args ) = @_;
18 my $e = MooseX::Storage::Engine->new( class => $class );
19 $class->new( $e->expand_object($data, @args) );
30 MooseX::Storage::Basic - The simplest level of serialization
38 our $VERSION = '0.01';
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 pack/unpack an
50 ## object in perl data structures
52 # pack the class into a hash
53 $p->pack(); # { __CLASS__ => 'Point-0.01', x => 10, y => 10 }
55 # unpack the hash into a class
56 my $p2 = Point->unpack({ __CLASS__ => 'Point-0.01', x => 10, y => 10 });
60 This is the most basic form of serialization. This is used by default
61 but the exported C<Storage> function.
69 =item B<unpack ($data)>
83 All complex software has bugs lurking in it, and this module is no
84 exception. If you find a bug please either email me, or add the bug
89 Chris Prather E<lt>chris.prather@iinteractive.comE<gt>
91 Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
93 =head1 COPYRIGHT AND LICENSE
95 Copyright 2007 by Infinity Interactive, Inc.
97 L<http://www.iinteractive.com>
99 This library is free software; you can redistribute it and/or modify
100 it under the same terms as Perl itself.