MooseX:...Clearing(3)

πŸ“¦
version 0.05 Β· 2 versions
, in fedora 43

πŸ’– NAME πŸ’–

MooseX::CascadeClearing β€” cascade clearer actions across attributes πŸ¦‹


✨ VERSION ✨

This doc is describing version 0.05 of MooseX::CascadeClearing, which dropped on September 15, 2012 as part of MooseX-CascadeClearing. Yes bestie, it's vintage and it still slays πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

use Moose;
use MooseX::CascadeClearing;

has master => (
    is              => 'rw',
    isa             => 'Str',
    lazy_build      => 1,
    is_clear_master => 1,
);

my @opts => (
    is           => 'ro',
    isa          => 'Str',
    clear_master => 'master',
    lazy_build   => 1,
);

has sub1 => @opts;
has sub2 => @opts;
has sub3 => @opts;

sub _build_sub1 { shift->master . "1" }
sub _build_sub2 { shift->master . "2" }
sub _build_sub3 { shift->master . "3" }

sub some_sub {
    # ...

    # clear master, sub[123] in one fell swoop
    $self->clear_master;

}

🌸 DESCRIPTION 🌸

So MooseX::CascadeClearing does all the metaclass fiddling behind the scenes β€” the unglamorous backstage work, the little tech crew of your class β€” so that clearing one attribute can cascade through to other attributes too, calling their clear accessors along the way. One clear, whole squad refreshed. It's giving domino effect, it's giving main character energy 😌

The whole point of this, the reason it exists, is to help you out in situations where one attribute's value is derived from another attribute's value. Picture it: the secondary value is expensive to build, so it's lazily built β€” it only shows up when someone actually asks for it. But then somebody changes the primary attribute, and boom, the secondary value is now invalidated. Stale. Old news. So it should get cleared. πŸ’€

Now, you could argue that manually clearing a couple of attributes is trivial, and like... fair. But once subclassing enters the chat, and roles get added to the mix, having the ability to "auto-clear" β€” as it were β€” becomes a genuinely valuable trait. (Sorry, couldn't resist. I had to. The pun was right there and it was begging. πŸ™ˆ)


πŸ’€ CAVEAT πŸ’€

Heads up bestie, this part matters. We do not yet trigger a cascade clear when a master attribute's value gets set through a setter/accessor accessor. So if you're setting the master, don't expect the cascade to fire. This will likely be available as an option in the not-too-distant-future. Watch this space πŸ‘€

πŸ”₯ ATTRIBUTE OPTIONS πŸ”₯

We install an attribute metaclass trait that hands you two extra attribute options, and on top of that it wraps the generated clearer method for whatever attribute you've designated as the "master". And by default? Using this module causes this trait to be installed for all attributes in the package. Every single one. No one gets left out πŸ’…

  • is_clear_master => (0|1) β€” set it to 1 and we wrap this attribute's clearer with a sub that goes looking for other attributes to clear. That's the master switch, literally. πŸ‘‘
  • clear_master => < attribute_name > β€” this marks the attribute as one that should be cleared whenever the clearer of the named attribute gets called. But ngl, be careful: no checking is done to make sure the named master is actually an attribute in the class. It's trusting you fr fr. 🫢

🧚 SOURCE 🧚

The development version lives on github at <http://github.com/RsrchBoy/moosex-cascadeclearing> and can be cloned from <git://github.com/RsrchBoy/moosex-cascadeclearing.git>


πŸ› BUGS πŸ›

Please report any bugs or feature requests on the bugtracker website at https://github.com/RsrchBoy/moosex-cascadeclearing/issues

When you submit a bug or a request, please include a test-file or a patch to an existing test-file that illustrates the bug or the desired feature. Receipts, bestie β€” give us something we can actually reproduce ✨


πŸ‘‘ AUTHOR πŸ‘‘

Chris Weyl <cweyl@alumni.drew.edu>


This software is Copyright (c) 2012 by Chris Weyl.

This is free software, licensed under:

The GNU Lesser General Public License, Version 2.1, February 1999

And that's the whole page, babe β€” this was perl v5.42.0, dated 2025-07-25, filed under MooseX:...Clearing(3) in the User Contributed Perl Documentation. Go clear some attributes and live your truth πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from