Version 0.32
[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
e44b5f54 6our $VERSION = '0.32';
69b45b7d 7our $AUTHORITY = 'cpan:STEVAN';
7b428d1f 8
e64b7302 9with 'MooseX::Storage::IO::File';
10
11sub store {
bf33d7c7 12 my ( $self, $filename, @args ) = @_;
13 MooseX::Storage::Engine::IO::AtomicFile->new( file => $filename )->store( $self->freeze(@args) );
e64b7302 14}
15
f82612bc 16no Moose::Role;
17
e64b7302 181;
19
20__END__
21
22=pod
23
24=head1 NAME
25
4fa64e86 26MooseX::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 70All complex software has bugs lurking in it, and this module is no
e64b7302 71exception. If you find a bug please either email me, or add the bug
72to cpan-RT.
73
74=head1 AUTHOR
75
76Chris Prather E<lt>chris.prather@iinteractive.comE<gt>
77
78Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
79
80=head1 COPYRIGHT AND LICENSE
81
1f3074ea 82Copyright 2007-2008 by Infinity Interactive, Inc.
e64b7302 83
84L<http://www.iinteractive.com>
85
86This library is free software; you can redistribute it and/or modify
87it under the same terms as Perl itself.
88
89=cut
90
91