foo
[gitmo/MooseX-Storage.git] / lib / MooseX / Storage / Engine / IO / File.pm
1
2 package MooseX::Storage::Engine::IO::File;
3 use Moose;
4
5 use IO::File;
6
7 has 'file' => (
8         is       => 'ro',
9         isa      => 'Str',      
10         required => 1,
11 );
12
13 sub load { 
14         my ($self) = @_;
15         my $fh = IO::File->new($self->file, 'r');
16         return do { local $/; <$fh>; };
17 }
18
19 sub store {
20         my ($self, $data) = @_;
21         my $fh = IO::File->new($self->file, 'w');
22         print $fh $data;
23 }
24
25 1;
26
27 __END__
28
29 =pod
30
31 =head1 NAME
32
33 MooseX::Storage::Engine::IO::File - The actually file storage mechanism.
34
35 =head1 DESCRIPTION
36
37 This provides the actual means to store data to a file.
38
39 =head1 METHODS
40
41 =over 4
42
43 =item B<file>
44
45 =item B<load>
46
47 =item B<store ($data)>
48
49 =back
50
51 =head2 Introspection
52
53 =over 4
54
55 =item B<meta>
56
57 =back
58
59 =head1 BUGS
60
61 All complex software has bugs lurking in it, and this module is no 
62 exception. If you find a bug please either email me, or add the bug
63 to cpan-RT.
64
65 =head1 AUTHOR
66
67 Chris Prather E<lt>chris.prather@iinteractive.comE<gt>
68
69 Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
70
71 =head1 COPYRIGHT AND LICENSE
72
73 Copyright 2007 by Infinity Interactive, Inc.
74
75 L<http://www.iinteractive.com>
76
77 This library is free software; you can redistribute it and/or modify
78 it under the same terms as Perl itself.
79
80 =cut