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