MooseX::AttributeFilter - MooX::AttributeFilter with cute antlers OwO
package My::Class; use Moose; use MooseX::AttributeFilter; has field => ( is => 'rw', filter => 'filterField', ); sub filterField { my $this = shift; return "filtered($_[0])"; } package main; my $obj = My::Class->new( field => "initial" ); $obj->field eq "filtered(initial)"; # True!
MooseX::AttributeFilter is a port of MooX::AttributeFilter to Moose.
A filter a method that is called before an attribute value is set (by accessor or constructor). It is called before coercions, type checks, and triggers.
It is called as a method (so receives the object) with the new attribute value as its first parameter, and the old attribute value as the second parameter. (When called from constructor, no old value, so only one parameter.) Its return value is used as the attribute value.
It is even called when an attribute value is build by builder methods or defaults.
See MooX::AttributeFilter for more details and for use cases.
Some parts don't work correctly in mutable classes. Mutable classes are slow anyway.
https://rt.cpan.org/Dist/Display.html?Queue=MooseX-AttributeFilter
Cute.
MooX::AttributeFilter, Moose.
MooseX::AttributeFilter::Trait::Attribute, MooseX::AttributeFilter::Trait::Attribute::Role.
Copyright (C) 2018 Little Princess Kitten <kitten@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
KITTEN <kitten@cpan.org>
https://metacpan.org/author/KITTEN
https://github.com/icklekitten
<3
To install MooseX::AttributeFilter, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::AttributeFilter
CPAN shell
perl -MCPAN -e shell install MooseX::AttributeFilter
For more information on module installation, please visit the detailed CPAN module installation guide.