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

NAME

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

SYNOPSIS

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

DESCRIPTION

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

SUPPORTED FORMATS

45       JSON
46       YAML
47       Storable
48

SUPPORTED I/O

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

METHODS

60       freeze ($type_desc)
61       thaw ($data, $type_desc)
62       load ($filename, $type_desc)
63       store ($filename, $type_desc)
64
65   Introspection
66       meta
67

BUGS

69       All complex software has bugs lurking in it, and this module is no
70       exception. If you find a bug please either email me, or add the bug to
71       cpan-RT.
72

AUTHOR

74       Stevan Little <stevan.little@iinteractive.com>
75
77       Copyright 2007-2008 by Infinity Interactive, Inc.
78
79       <http://www.iinteractive.com>
80
81       This library is free software; you can redistribute it and/or modify it
82       under the same terms as Perl itself.
83
84
85
86perl v5.12.0                      2009-07-14      MooseX::Storage::Deferred(3)
Impressum