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