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