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