1MooseX::Storage::TraitsU:s:eOrnlCyoWnhterniBbuuitletdM(o3Po)esrelX:D:oSctuomreangtea:t:iTornaits::OnlyWhenBuilt(3)
2
3
4

NAME

6       MooseX::Storage::Traits::OnlyWhenBuilt - A custom trait to bypass
7       serialization
8

VERSION

10       version 0.52
11

SYNOPSIS

13           {   package Point;
14               use Moose;
15               use MooseX::Storage;
16
17               with Storage( traits => [qw|OnlyWhenBuilt|] );
18
19               has 'x' => (is => 'rw', lazy_build => 1 );
20               has 'y' => (is => 'rw', predicate => '_has_y' );
21               has 'z' => (is => 'rw', builder => '_build_z' );
22
23               sub _build_x { 3 }
24               sub _build_y { expensive_computation() }
25               sub _build_z { 3 }
26
27           }
28
29           my $p = Point->new( 'x' => 4 );
30
31           # the result of ->pack will contain:
32           # { x => 4, z => 3 }
33           $p->pack;
34

DESCRIPTION

36       Sometimes you don't want a particular attribute to be part of the
37       serialization if it has not been built yet. If you invoke "Storage()"
38       as outlined in the "Synopsis", only attributes that have been built
39       (i.e., where the predicate returns 'true') will be serialized.  This
40       avoids any potentially expensive computations.
41
42       See the SYNOPSIS for a nice example that can be easily cargo-culted.
43

SUPPORT

45       Bugs may be submitted through the RT bug tracker
46       <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Storage> (or
47       bug-MooseX-Storage@rt.cpan.org <mailto:bug-MooseX-
48       Storage@rt.cpan.org>).
49
50       There is also a mailing list available for users of this distribution,
51       at <http://lists.perl.org/list/moose.html>.
52
53       There is also an irc channel available for users of this distribution,
54       at "#moose" on "irc.perl.org" <irc://irc.perl.org/#moose>.
55

AUTHORS

57       ·   Chris Prather <chris.prather@iinteractive.com>
58
59       ·   Stevan Little <stevan.little@iinteractive.com>
60
61       ·   יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
62
64       This software is copyright (c) 2007 by Infinity Interactive, Inc.
65
66       This is free software; you can redistribute it and/or modify it under
67       the same terms as the Perl 5 programming language system itself.
68
69
70
71perl v5.28.0                      2016M-o0o6s-e2X2::Storage::Traits::OnlyWhenBuilt(3)
Impressum