more tweaks for 0.01
[gitmo/MooseX-Storage.git] / lib / MooseX / Storage / Basic.pm
CommitLineData
ec9c1923 1
2package MooseX::Storage::Basic;
3use Moose::Role;
4
5use MooseX::Storage::Engine;
6
7b428d1f 7our $VERSION = '0.01';
8
ec9c1923 9sub pack {
10 my $self = shift;
11 my $e = MooseX::Storage::Engine->new( object => $self );
12 $e->collapse_object;
13}
14
15sub unpack {
16 my ( $class, $data ) = @_;
17 my $e = MooseX::Storage::Engine->new( class => $class );
18 $class->new( $e->expand_object($data) );
19}
20
211;
22
23__END__
24
25=pod
26
27=head1 NAME
28
1390c23d 29MooseX::Storage::Basic - The simplest level of serialization
ec9c1923 30
31=head1 SYNOPSIS
32
1390c23d 33 package Point;
34 use Moose;
35 use MooseX::Storage;
36
37 with Storage;
38
39 has 'x' => (is => 'rw', isa => 'Int');
40 has 'y' => (is => 'rw', isa => 'Int');
41
42 1;
43
44 my $p = Point->new(x => 10, y => 10);
45
46 ## methods to pack/unpack an
47 ## object in perl data structures
48
49 # pack the class into a hash
50 $p->pack(); # { __CLASS__ => 'Point', x => 10, y => 10 }
51
52 # unpack the hash into a class
53 my $p2 = Point->unpack({ __CLASS__ => 'Point', x => 10, y => 10 });
54
ec9c1923 55=head1 DESCRIPTION
56
1390c23d 57This is the most basic form of serialization. This is used by default
58but the exported C<Storage> function.
59
ec9c1923 60=head1 METHODS
61
62=over 4
63
64=item B<pack>
65
66=item B<unpack ($data)>
67
68=back
69
70=head2 Introspection
71
72=over 4
73
74=item B<meta>
75
76=back
77
78=head1 BUGS
79
80All complex software has bugs lurking in it, and this module is no
81exception. If you find a bug please either email me, or add the bug
82to cpan-RT.
83
84=head1 AUTHOR
85
86Chris Prather E<lt>chris.prather@iinteractive.comE<gt>
87
88Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
89
90=head1 COPYRIGHT AND LICENSE
91
92Copyright 2007 by Infinity Interactive, Inc.
93
94L<http://www.iinteractive.com>
95
96This library is free software; you can redistribute it and/or modify
97it under the same terms as Perl itself.
98
99=cut