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