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