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