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 package Point;
10 use Moose;
11 use MooseX::Storage;
12
13 our $VERSION = '0.01';
14
15 with Storage;
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 pack/unpack an
25 ## object in perl data structures
26
27 # pack the class into a hash
28 $p->pack(); # { __CLASS__ => 'Point-0.01', x => 10, y => 10 }
29
30 # unpack the hash into a class
31 my $p2 = Point->unpack({ __CLASS__ => 'Point-0.01', x => 10, y => 10 });
32
33 # unpack the hash, with insertion of paramaters
34 my $p3 = Point->unpack( $p->pack, inject => { x => 11 } );
35
37 This is the most basic form of serialization. This is used by default
38 but the exported "Storage" function.
39
41 pack ([ disable_cycle_check = 1])>
42 Providing the "disable_cycle_check" argument disables checks for
43 any cyclical references. The current implementation for this check
44 is rather naive, so if you know what you are doing, you can bypass
45 this check.
46
47 This trait is applied on a perl-case basis. To set this flag for
48 all objects that inherit from this role, see
49 MooseX::Storage::Traits::DisableCycleDetection.
50
51 unpack ($data [, insert = { key => val, ... } ] )>
52 Providing the "insert" argument let's you supply additional
53 arguments to the class' "new" function, or override ones from the
54 serialized data.
55
56 Introspection
57 meta
58
60 All complex software has bugs lurking in it, and this module is no
61 exception. If you find a bug please either email me, or add the bug to
62 cpan-RT.
63
65 Chris Prather <chris.prather@iinteractive.com>
66
67 Stevan Little <stevan.little@iinteractive.com>
68
70 Copyright 2007-2008 by Infinity Interactive, Inc.
71
72 <http://www.iinteractive.com>
73
74 This library is free software; you can redistribute it and/or modify it
75 under the same terms as Perl itself.
76
77
78
79perl v5.12.0 2009-07-14 MooseX::Storage::Basic(3)