0.12
[gitmo/MooseX-Storage.git] / lib / MooseX / Storage / IO / AtomicFile.pm
CommitLineData
e64b7302 1
2package MooseX::Storage::IO::AtomicFile;
3use Moose::Role;
4
5use MooseX::Storage::Engine::IO::AtomicFile;
6
69b45b7d 7our $VERSION = '0.01';
8our $AUTHORITY = 'cpan:STEVAN';
7b428d1f 9
e64b7302 10with 'MooseX::Storage::IO::File';
11
12sub store {
bf33d7c7 13 my ( $self, $filename, @args ) = @_;
14 MooseX::Storage::Engine::IO::AtomicFile->new( file => $filename )->store( $self->freeze(@args) );
e64b7302 15}
16
171;
18
19__END__
20
21=pod
22
23=head1 NAME
24
4fa64e86 25MooseX::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;
32
33 with Storage('format' => 'JSON', 'io' => 'AtomicFile');
34
35 has 'x' => (is => 'rw', isa => 'Int');
36 has 'y' => (is => 'rw', isa => 'Int');
37
38 1;
39
40 my $p = Point->new(x => 10, y => 10);
41
42 ## methods to load/store a class
43 ## on the file system
44
45 $p->store('my_point.json');
46
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
69All complex software has bugs lurking in it, and this module is no
70exception. If you find a bug please either email me, or add the bug
71to cpan-RT.
72
73=head1 AUTHOR
74
75Chris Prather E<lt>chris.prather@iinteractive.comE<gt>
76
77Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
78
79=head1 COPYRIGHT AND LICENSE
80
1f3074ea 81Copyright 2007-2008 by Infinity Interactive, Inc.
e64b7302 82
83L<http://www.iinteractive.com>
84
85This library is free software; you can redistribute it and/or modify
86it under the same terms as Perl itself.
87
88=cut
89
90