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