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