foo
[gitmo/MooseX-Storage.git] / lib / MooseX / Storage / IO / File.pm
1
2 package MooseX::Storage::IO::File;
3 use Moose::Role;
4
5 use MooseX::Storage::Engine::IO::File;
6
7 requires 'thaw';
8 requires 'freeze';
9
10 sub load {
11     my ( $class, $filename ) = @_;
12     $class->thaw( MooseX::Storage::Engine::IO::File->new( file => $filename )->load() );
13 }
14
15 sub store {
16     my ( $self, $filename ) = @_;
17     MooseX::Storage::Engine::IO::File->new( file => $filename )->store( $self->freeze() );
18 }
19
20 1;
21
22 __END__
23
24 =pod
25
26 =head1 NAME
27
28 MooseX::Storage::IO::File
29
30 =head1 SYNOPSIS
31
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');
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
72 All complex software has bugs lurking in it, and this module is no 
73 exception. If you find a bug please either email me, or add the bug
74 to cpan-RT.
75
76 =head1 AUTHOR
77
78 Chris Prather E<lt>chris.prather@iinteractive.comE<gt>
79
80 Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
81
82 =head1 COPYRIGHT AND LICENSE
83
84 Copyright 2007 by Infinity Interactive, Inc.
85
86 L<http://www.iinteractive.com>
87
88 This library is free software; you can redistribute it and/or modify
89 it under the same terms as Perl itself.
90
91 =cut
92
93