File Coverage

blib/lib/MooseX/Storage/IO/File.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 20 20 100.0


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