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

NAME

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

VERSION

9       This document describes version 0.05 of MooseX::CascadeClearing -
10       released September 15, 2012 as part of MooseX-CascadeClearing.
11

SYNOPSIS

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

DESCRIPTION

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

CAVEAT

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

ATTRIBUTE OPTIONS

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

SOURCE

82       The development version is on github at
83       <http://github.com/RsrchBoy/moosex-cascadeclearing> and may be cloned
84       from <git://github.com/RsrchBoy/moosex-cascadeclearing.git>
85

BUGS

87       Please report any bugs or feature requests on the bugtracker website
88       https://github.com/RsrchBoy/moosex-cascadeclearing/issues
89
90       When submitting a bug or request, please include a test-file or a patch
91       to an existing test-file that illustrates the bug or desired feature.
92

AUTHOR

94       Chris Weyl <cweyl@alumni.drew.edu>
95
97       This software is Copyright (c) 2012 by Chris Weyl.
98
99       This is free software, licensed under:
100
101         The GNU Lesser General Public License, Version 2.1, February 1999
102
103
104
105perl v5.34.0                      2021-07-22        MooseX::CascadeClearing(3)
Impressum