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