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