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