line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Storage::IO::AtomicFile; |
2
|
|
|
|
|
|
|
# ABSTRACT: An Atomic File I/O role |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.52'; |
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
1590
|
use Moose::Role; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
21
|
|
7
|
3
|
|
|
3
|
|
12042
|
use MooseX::Storage::Engine::IO::AtomicFile; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
94
|
|
8
|
3
|
|
|
3
|
|
14
|
use namespace::autoclean; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
11
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'MooseX::Storage::IO::File'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub store { |
13
|
4
|
|
|
4
|
1
|
12318
|
my ( $self, $filename, @args ) = @_; |
14
|
4
|
|
|
|
|
43
|
MooseX::Storage::Engine::IO::AtomicFile->new( file => $filename )->store( $self->freeze(@args) ); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
3
|
|
273
|
no Moose::Role; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
20
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
1; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__END__ |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=pod |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=encoding UTF-8 |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 NAME |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
MooseX::Storage::IO::AtomicFile - An Atomic File I/O role |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 VERSION |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
version 0.52 |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SYNOPSIS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
package Point; |
38
|
|
|
|
|
|
|
use Moose; |
39
|
|
|
|
|
|
|
use MooseX::Storage; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
with Storage('format' => 'JSON', 'io' => 'AtomicFile'); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has 'x' => (is => 'rw', isa => 'Int'); |
44
|
|
|
|
|
|
|
has 'y' => (is => 'rw', isa => 'Int'); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $p = Point->new(x => 10, y => 10); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
## methods to load/store a class |
51
|
|
|
|
|
|
|
## on the file system |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$p->store('my_point.json'); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $p2 = Point->load('my_point.json'); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 METHODS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=over 4 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item B<load ($filename)> |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item B<store ($filename)> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=back |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 SUPPORT |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Storage> |
70
|
|
|
|
|
|
|
(or L<bug-MooseX-Storage@rt.cpan.org|mailto:bug-MooseX-Storage@rt.cpan.org>). |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
73
|
|
|
|
|
|
|
L<http://lists.perl.org/list/moose.html>. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
76
|
|
|
|
|
|
|
L<C<#moose> on C<irc.perl.org>|irc://irc.perl.org/#moose>. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 AUTHORS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=over 4 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item * |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Chris Prather <chris.prather@iinteractive.com> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item * |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Stevan Little <stevan.little@iinteractive.com> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
×××× ×§××'×× (Yuval Kogman) <nothingmuch@woobling.org> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This software is copyright (c) 2007 by Infinity Interactive, Inc. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
101
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |