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