1MooseX::CascadeClearingU(s3e)r Contributed Perl DocumentaMtoioosneX::CascadeClearing(3)
2
3
4

NAME

6       MooseX::CascadeClearing - Cascade clearer actions across attributes
7

VERSION

9       Version 0.02
10

SYNOPSIS

12           use Moose;
13           use MooseX::CascadeClearing;
14
15           has master => (
16               is              => 'rw',
17               isa             => 'Str',
18               lazy_build      => 1,
19               is_clear_master => 1,
20           );
21
22           my @opts = (
23               is => 'ro', isa => 'Str', clear_master => 'master', lazy_build => 1,
24           );
25
26           has sub1 => @opts;
27           has sub2 => @opts;
28           has sub3 => @opts;
29
30           sub _build_sub1 { shift->master . "1" }
31           sub _build_sub2 { shift->master . "2" }
32           sub _build_sub3 { shift->master . "3" }
33
34           sub some_sub {
35               # ...
36
37               # clear master, sub[123] in one fell swoop
38               $self->clear_master;
39
40           }
41

DESCRIPTION

43       MooseX::CascadeClearing does the necessary metaclass fiddling to allow
44       an clearing one attribute to be cascaded through to other attributes as
45       well, calling their clearers.
46
47       The intended purpose of this is to assist in situations where the value
48       of one attribute is derived from the value of another attribute -- say
49       a situation where the secondary value is expensive to derive and is
50       thus lazily built.  A change to the primary attribute's value would
51       invalidate the secondary value and as such the secondary should be
52       cleared.  While it could be argued that this is trivial to do manually
53       for a few attributes, once we consider subclassing and adding in roles
54       the ability to "auto-clear", as it were, is a valuable trait.  (Sorry,
55       couldn't resist.)
56

CAVEAT

58       We don't yet trigger a cascade clear on a master attribute's value
59       being set through a setter/accessor accessor.  This will likely be
60       available as an option in the not-too-distant-future.
61

ATTRIBUTE OPTIONS

63       We install an attribute metaclass trait that provides two additional
64       atttribute options, as well as wraps the generated clearer method for a
65       designated "master" attribute.  By default, use'ing this module causes
66       this trait to be installed for all attributes in the package.
67
68       is_clear_master => (0|1)
69           If set to 1, we wrap this attribute's clearer with a sub that looks
70           for other attributes to clear.
71
72       clear_master => Str
73           Marks this attribute as one that should be cleared when the named
74           attribute's clearer is called.  Note that no checking is done to
75           ensure that the named master is actually an attribute in the class.
76

AUTHOR

78       Chris Weyl, "<cweyl at alumni.drew.edu>"
79

BUGS

81       Please report any bugs or feature requests to
82       "bug-moosex-cascadeclearing at rt.cpan.org", or through the web
83       interface at
84       http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-CascadeClearing
85       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-
86       CascadeClearing>.  I will be notified, and then you'llautomatically be
87       notified of progress on your bug as I make changes.
88

SUPPORT

90       You can find documentation for this module with the perldoc command.
91
92           perldoc MooseX::CascadeClearing
93
94       You can also look for information at:
95
96       ·   RT: CPAN's request tracker
97
98           http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-CascadeClearing
99           <http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-CascadeClearing>
100
101       ·   AnnoCPAN: Annotated CPAN documentation
102
103           http://annocpan.org/dist/MooseX-CascadeClearing
104           <http://annocpan.org/dist/MooseX-CascadeClearing>
105
106       ·   CPAN Ratings
107
108           http://cpanratings.perl.org/d/MooseX-CascadeClearing
109           <http://cpanratings.perl.org/d/MooseX-CascadeClearing>
110
111       ·   Search CPAN
112
113           http://search.cpan.org/dist/MooseX-CascadeClearing/
114           <http://search.cpan.org/dist/MooseX-CascadeClearing/>
115

ACKNOWLEDGEMENTS

117       MooseX::AlwaysCoerce, for inspiring me to do this in a slightly more
118       sane fashion than I was previously.
119
120       And of course the Moose team, who have made my life significantly
121       easier (and more fun!) since 0.17 :)
122
124       Copyright (c) 2009, Chris Weyl "<cweyl@alumni.drew.edu>".
125
126       This library is free software; you can redistribute it and/or modify it
127       under the terms of the GNU Lesser General Public License as published
128       by the Free Software Foundation; either version 2.1 of the License, or
129       (at your option) any later version.
130
131       This library is distributed in the hope that it will be useful, but
132       WITHOUT ANY WARRANTY; without even the implied warranty of
133       MERCHANTABILITY or FITNESS OR A PARTICULAR PURPOSE.
134
135       See the GNU Lesser General Public License for more details.
136
137       You should have received a copy of the GNU Lesser General Public
138       License along with this library; if not, write to the
139
140           Free Software Foundation, Inc.,
141           59 Temple Place, Suite 330,
142           Boston, MA  02111-1307 USA
143
144
145
146perl v5.12.2                      2010-09-06        MooseX::CascadeClearing(3)
Impressum