1MooseX::Storage::Basic(U3s)er Contributed Perl DocumentatMiooonseX::Storage::Basic(3)
2
3
4
6 MooseX::Storage::Basic - The simplest level of serialization
7
9 version 0.52
10
12 package Point;
13 use Moose;
14 use MooseX::Storage;
15
16 with Storage;
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 pack/unpack an
26 ## object in perl data structures
27
28 # pack the class into a hash
29 $p->pack(); # { __CLASS__ => 'Point-0.01', x => 10, y => 10 }
30
31 # unpack the hash into a class
32 my $p2 = Point->unpack({ __CLASS__ => 'Point-0.01', x => 10, y => 10 });
33
34 # unpack the hash, with injection of additional paramaters
35 my $p3 = Point->unpack( $p->pack, inject => { x => 11 } );
36
38 This is the most basic form of serialization. This is used by default
39 but the exported "Storage" function.
40
42 pack ([ disable_cycle_check = 1])>
43 Providing the "disable_cycle_check" argument disables checks for
44 any cyclical references. The current implementation for this check
45 is rather naive, so if you know what you are doing, you can bypass
46 this check.
47
48 This trait is applied on a perl-case basis. To set this flag for
49 all objects that inherit from this role, see
50 MooseX::Storage::Traits::DisableCycleDetection.
51
52 unpack ($data [, inject = { key => val, ... } ] )>
53 Providing the "inject" argument lets you supply additional
54 arguments to the class' "new" function, or override ones from the
55 serialized data.
56
58 Bugs may be submitted through the RT bug tracker
59 <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Storage> (or
60 bug-MooseX-Storage@rt.cpan.org <mailto:bug-MooseX-
61 Storage@rt.cpan.org>).
62
63 There is also a mailing list available for users of this distribution,
64 at <http://lists.perl.org/list/moose.html>.
65
66 There is also an irc channel available for users of this distribution,
67 at "#moose" on "irc.perl.org" <irc://irc.perl.org/#moose>.
68
70 · Chris Prather <chris.prather@iinteractive.com>
71
72 · Stevan Little <stevan.little@iinteractive.com>
73
74 · יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
75
77 This software is copyright (c) 2007 by Infinity Interactive, Inc.
78
79 This is free software; you can redistribute it and/or modify it under
80 the same terms as the Perl 5 programming language system itself.
81
82
83
84perl v5.30.0 2019-07-26 MooseX::Storage::Basic(3)