Commit | Line | Data |
a23e18d7 |
1 | |
4d1850a6 |
2 | package MooseX::Storage::Engine::IO::File; |
a23e18d7 |
3 | use Moose; |
4 | |
5 | use IO::File; |
6 | |
c86a46cc |
7 | our $VERSION = '0.02'; |
7b428d1f |
8 | |
ec9c1923 |
9 | has 'file' => ( |
10 | is => 'ro', |
11 | isa => 'Str', |
a23e18d7 |
12 | required => 1, |
13 | ); |
14 | |
15 | sub 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 | |
22 | sub 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 |
29 | 1; |
30 | |
31 | __END__ |
32 | |
33 | =pod |
34 | |
35 | =head1 NAME |
36 | |
b477f392 |
37 | MooseX::Storage::Engine::IO::File - The actually file storage mechanism. |
ec9c1923 |
38 | |
39 | =head1 DESCRIPTION |
40 | |
b477f392 |
41 | This 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 | |
65 | All complex software has bugs lurking in it, and this module is no |
66 | exception. If you find a bug please either email me, or add the bug |
67 | to cpan-RT. |
68 | |
69 | =head1 AUTHOR |
70 | |
71 | Chris Prather E<lt>chris.prather@iinteractive.comE<gt> |
72 | |
73 | Stevan Little E<lt>stevan.little@iinteractive.comE<gt> |
74 | |
75 | =head1 COPYRIGHT AND LICENSE |
76 | |
77 | Copyright 2007 by Infinity Interactive, Inc. |
78 | |
79 | L<http://www.iinteractive.com> |
80 | |
81 | This library is free software; you can redistribute it and/or modify |
82 | it under the same terms as Perl itself. |
83 | |
84 | =cut |