line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Storage::IO::File; |
2
|
|
|
|
|
|
|
# ABSTRACT: A basic File I/O role |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.50'; |
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
4062
|
use Moose::Role; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
43
|
|
7
|
6
|
|
|
6
|
|
29818
|
use MooseX::Storage::Engine::IO::File; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
178
|
|
8
|
6
|
|
|
6
|
|
36
|
use namespace::autoclean; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
43
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
requires 'thaw'; |
11
|
|
|
|
|
|
|
requires 'freeze'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub load { |
14
|
9
|
|
|
9
|
1
|
2620
|
my ( $class, $filename, @args ) = @_; |
15
|
9
|
|
|
|
|
83
|
$class->thaw( MooseX::Storage::Engine::IO::File->new( file => $filename )->load(), @args ); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub store { |
19
|
5
|
|
|
5
|
1
|
20161
|
my ( $self, $filename, @args ) = @_; |
20
|
5
|
|
|
|
|
44
|
MooseX::Storage::Engine::IO::File->new( file => $filename )->store( $self->freeze(@args) ); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
6
|
|
|
6
|
|
943
|
no Moose::Role; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
45
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
__END__ |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=pod |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=encoding UTF-8 |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
MooseX::Storage::IO::File - A basic File I/O role |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 VERSION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
version 0.50 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 SYNOPSIS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
package Point; |
44
|
|
|
|
|
|
|
use Moose; |
45
|
|
|
|
|
|
|
use MooseX::Storage; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
with Storage('format' => 'JSON', 'io' => 'File'); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has 'x' => (is => 'rw', isa => 'Int'); |
50
|
|
|
|
|
|
|
has 'y' => (is => 'rw', isa => 'Int'); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $p = Point->new(x => 10, y => 10); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
## methods to load/store a class |
57
|
|
|
|
|
|
|
## on the file system |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$p->store('my_point.json'); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $p2 = Point->load('my_point.json'); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 METHODS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=over 4 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item B<load ($filename)> |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item B<store ($filename)> |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=back |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 Introspection |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=over 4 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item B<meta> |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=back |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 BUGS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
All complex software has bugs lurking in it, and this module is no |
84
|
|
|
|
|
|
|
exception. If you find a bug please or add the bug to cpan-RT |
85
|
|
|
|
|
|
|
at L<https://rt.cpan.org/Dist/Display.html?Queue=MooseX-Storage>. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 AUTHORS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over 4 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item * |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Chris Prather <chris.prather@iinteractive.com> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item * |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Stevan Little <stevan.little@iinteractive.com> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item * |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
×××× ×§××'×× (Yuval Kogman) <nothingmuch@woobling.org> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=back |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This software is copyright (c) 2007 by Infinity Interactive, Inc.. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
110
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |