more tweaks for 0.01
[gitmo/MooseX-Storage.git] / lib / MooseX / Storage / IO / File.pm
CommitLineData
bff7e5f7 1
2package MooseX::Storage::IO::File;
a23e18d7 3use Moose::Role;
4
4d1850a6 5use MooseX::Storage::Engine::IO::File;
6
7b428d1f 7our $VERSION = '0.01';
8
4d1850a6 9requires 'thaw';
10requires 'freeze';
a23e18d7 11
12sub load {
13 my ( $class, $filename ) = @_;
4d1850a6 14 $class->thaw( MooseX::Storage::Engine::IO::File->new( file => $filename )->load() );
bff7e5f7 15}
16
17sub store {
a23e18d7 18 my ( $self, $filename ) = @_;
4d1850a6 19 MooseX::Storage::Engine::IO::File->new( file => $filename )->store( $self->freeze() );
a23e18d7 20}
21
221;
23
24__END__
25
26=pod
27
ec9c1923 28=head1 NAME
29
30MooseX::Storage::IO::File
31
32=head1 SYNOPSIS
33
b477f392 34 package Point;
35 use Moose;
36 use MooseX::Storage;
37
38 with Storage('format' => 'JSON', 'io' => 'File');
39
40 has 'x' => (is => 'rw', isa => 'Int');
41 has 'y' => (is => 'rw', isa => 'Int');
42
43 1;
44
45 my $p = Point->new(x => 10, y => 10);
46
47 ## methods to load/store a class
48 ## on the file system
49
50 $p->store('my_point.json');
51
52 my $p2 = Point->load('my_point.json');
ec9c1923 53
54=head1 METHODS
55
56=over 4
57
58=item B<load ($filename)>
59
60=item B<store ($filename)>
61
62=back
63
64=head2 Introspection
65
66=over 4
67
68=item B<meta>
69
70=back
71
72=head1 BUGS
73
74All complex software has bugs lurking in it, and this module is no
75exception. If you find a bug please either email me, or add the bug
76to cpan-RT.
77
78=head1 AUTHOR
79
80Chris Prather E<lt>chris.prather@iinteractive.comE<gt>
81
82Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
83
84=head1 COPYRIGHT AND LICENSE
85
86Copyright 2007 by Infinity Interactive, Inc.
87
88L<http://www.iinteractive.com>
89
90This library is free software; you can redistribute it and/or modify
91it under the same terms as Perl itself.
92
a23e18d7 93=cut
94
ec9c1923 95