1MooseX::Storage::DeferrUesde(r3)Contributed Perl DocumenMtoaotsieoXn::Storage::Deferred(3)
2
3
4

NAME

6       MooseX::Storage::Deferred - A role for indecisive programmers
7

VERSION

9       version 0.53
10

SYNOPSIS

12         package Point;
13         use Moose;
14         use MooseX::Storage;
15
16         with 'MooseX::Storage::Deferred';
17
18         has 'x' => (is => 'rw', isa => 'Int');
19         has 'y' => (is => 'rw', isa => 'Int');
20
21         1;
22
23         my $p = Point->new(x => 10, y => 10);
24
25         ## methods to freeze/thaw into
26         ## a specified serialization format
27         ## (in this case JSON)
28
29         # pack the class into a JSON string
30         $p->freeze({ format => 'JSON' }); # { "__CLASS__" : "Point", "x" : 10, "y" : 10 }
31
32         # pack the class into a JSON string using parameterized JSONpm role
33         $p->freeze({ format => [ JSONpm => { json_opts => { pretty => 1 } } ] });
34
35         # unpack the JSON string into a class
36         my $p2 = Point->thaw(
37             '{ "__CLASS__" : "Point", "x" : 10, "y" : 10 }',
38             { format => 'JSON' }
39         );
40

DESCRIPTION

42       This role is designed for those times when you need to serialize into
43       many different formats or I/O options.
44
45       It basically allows you to choose the format and IO options only when
46       you actually use them (see the SYNOPSIS for more info)
47

SUPPORTED FORMATS

49       JSON
50       JSONpm
51       YAML
52       Storable
53

SUPPORTED I/O

55       File
56       AtomicFile
57
58       NOTE: The StorableFile I/O option is not supported, this is because it
59       does not mix well with options who also have a "thaw" and "freeze"
60       methods like this. It is possible to probably work around this issue,
61       but I don't currently have the need for it. If you need this supported,
62       talk to me and I will see what I can do.
63

METHODS

65       freeze ($type_desc)
66       thaw ($data, $type_desc)
67       load ($filename, $type_desc)
68       store ($filename, $type_desc)
69

SUPPORT

71       Bugs may be submitted through the RT bug tracker
72       <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Storage> (or
73       bug-MooseX-Storage@rt.cpan.org <mailto:bug-MooseX-
74       Storage@rt.cpan.org>).
75
76       There is also a mailing list available for users of this distribution,
77       at <http://lists.perl.org/list/moose.html>.
78
79       There is also an irc channel available for users of this distribution,
80       at "#moose" on "irc.perl.org" <irc://irc.perl.org/#moose>.
81

AUTHORS

83       •   Chris Prather <chris.prather@iinteractive.com>
84
85       •   Stevan Little <stevan.little@iinteractive.com>
86
87       •   יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
88
90       This software is copyright (c) 2007 by Infinity Interactive, Inc.
91
92       This is free software; you can redistribute it and/or modify it under
93       the same terms as the Perl 5 programming language system itself.
94
95
96
97perl v5.34.0                      2021-07-22      MooseX::Storage::Deferred(3)
Impressum