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