Commit | Line | Data |
---|---|---|
e64b7302 | 1 | |
2 | package MooseX::Storage::IO::AtomicFile; | |
3 | use Moose::Role; | |
4 | ||
5 | use MooseX::Storage::Engine::IO::AtomicFile; | |
6 | ||
5ca52230 | 7 | our $VERSION = '0.18'; |
69b45b7d | 8 | our $AUTHORITY = 'cpan:STEVAN'; |
7b428d1f | 9 | |
e64b7302 | 10 | with 'MooseX::Storage::IO::File'; |
11 | ||
12 | sub store { | |
bf33d7c7 | 13 | my ( $self, $filename, @args ) = @_; |
14 | MooseX::Storage::Engine::IO::AtomicFile->new( file => $filename )->store( $self->freeze(@args) ); | |
e64b7302 | 15 | } |
16 | ||
17 | 1; | |
18 | ||
19 | __END__ | |
20 | ||
21 | =pod | |
22 | ||
23 | =head1 NAME | |
24 | ||
4fa64e86 | 25 | MooseX::Storage::IO::AtomicFile - An Atomic File I/O role |
e64b7302 | 26 | |
27 | =head1 SYNOPSIS | |
28 | ||
b477f392 | 29 | package Point; |
30 | use Moose; | |
31 | use MooseX::Storage; | |
ec725183 | 32 | |
b477f392 | 33 | with Storage('format' => 'JSON', 'io' => 'AtomicFile'); |
ec725183 | 34 | |
b477f392 | 35 | has 'x' => (is => 'rw', isa => 'Int'); |
36 | has 'y' => (is => 'rw', isa => 'Int'); | |
ec725183 | 37 | |
b477f392 | 38 | 1; |
ec725183 | 39 | |
b477f392 | 40 | my $p = Point->new(x => 10, y => 10); |
ec725183 | 41 | |
42 | ## methods to load/store a class | |
b477f392 | 43 | ## on the file system |
ec725183 | 44 | |
b477f392 | 45 | $p->store('my_point.json'); |
ec725183 | 46 | |
b477f392 | 47 | my $p2 = Point->load('my_point.json'); |
e64b7302 | 48 | |
49 | =head1 METHODS | |
50 | ||
51 | =over 4 | |
52 | ||
53 | =item B<load ($filename)> | |
54 | ||
55 | =item B<store ($filename)> | |
56 | ||
57 | =back | |
58 | ||
59 | =head2 Introspection | |
60 | ||
61 | =over 4 | |
62 | ||
63 | =item B<meta> | |
64 | ||
65 | =back | |
66 | ||
67 | =head1 BUGS | |
68 | ||
ec725183 | 69 | All complex software has bugs lurking in it, and this module is no |
e64b7302 | 70 | exception. If you find a bug please either email me, or add the bug |
71 | to cpan-RT. | |
72 | ||
73 | =head1 AUTHOR | |
74 | ||
75 | Chris Prather E<lt>chris.prather@iinteractive.comE<gt> | |
76 | ||
77 | Stevan Little E<lt>stevan.little@iinteractive.comE<gt> | |
78 | ||
79 | =head1 COPYRIGHT AND LICENSE | |
80 | ||
1f3074ea | 81 | Copyright 2007-2008 by Infinity Interactive, Inc. |
e64b7302 | 82 | |
83 | L<http://www.iinteractive.com> | |
84 | ||
85 | This library is free software; you can redistribute it and/or modify | |
86 | it under the same terms as Perl itself. | |
87 | ||
88 | =cut | |
89 | ||
90 |