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