add comment about YAML::LibYAML
[gitmo/MooseX-Storage.git] / lib / MooseX / Storage / Format / YAML.pm
CommitLineData
6f0912d0 1
2package MooseX::Storage::Format::YAML;
3use Moose::Role;
4
ea189007 5# When I add YAML::LibYAML
6# Tests break because tye YAML is invalid...?
7# -dcp
8
6f0912d0 9use Best [
10 [ qw[YAML::Syck YAML] ],
11 [ qw[Load Dump] ]
12];
13
98ae09f0 14our $VERSION = '0.02';
7b428d1f 15
6f0912d0 16requires 'pack';
17requires 'unpack';
18
19sub thaw {
ea189007 20 my ( $class, $yaml, @args ) = @_;
21 $class->unpack( Load($yaml), @args );
6f0912d0 22}
23
24sub freeze {
98ae09f0 25 my ( $self, @args ) = @_;
26 Dump( $self->pack(@args) );
6f0912d0 27}
28
291;
30
31__END__
32
33=pod
34
35=head1 NAME
36
37MooseX::Storage::Format::YAML
38
39=head1 SYNOPSIS
40
1390c23d 41 package Point;
42 use Moose;
43 use MooseX::Storage;
44
45 with Storage('format' => 'YAML');
46
47 has 'x' => (is => 'rw', isa => 'Int');
48 has 'y' => (is => 'rw', isa => 'Int');
49
50 1;
51
52 my $p = Point->new(x => 10, y => 10);
53
54 ## methods to freeze/thaw into
55 ## a specified serialization format
56 ## (in this case YAML)
57
58 # pack the class into a YAML string
59 $p->freeze();
60
61 # ----
62 # __CLASS__: "Point"
63 # x: 10
64 # y: 10
65
66 # unpack the JSON string into a class
67 my $p2 = Point->thaw(<<YAML);
68 ----
69 __CLASS__: "Point"
70 x: 10
71 y: 10
72 YAML
6f0912d0 73
74=head1 METHODS
75
76=over 4
77
78=item B<freeze>
79
1390c23d 80=item B<thaw ($yaml)>
6f0912d0 81
82=back
83
84=head2 Introspection
85
86=over 4
87
88=item B<meta>
89
90=back
91
92=head1 BUGS
93
94All complex software has bugs lurking in it, and this module is no
95exception. If you find a bug please either email me, or add the bug
96to cpan-RT.
97
98=head1 AUTHOR
99
100Chris Prather E<lt>chris.prather@iinteractive.comE<gt>
101
102Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
103
104=head1 COPYRIGHT AND LICENSE
105
106Copyright 2007 by Infinity Interactive, Inc.
107
108L<http://www.iinteractive.com>
109
110This library is free software; you can redistribute it and/or modify
111it under the same terms as Perl itself.
112
113=cut
114
115