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