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