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