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