The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MooseX::AttributeFilter::Trait::Attribute - trait for filtered attributes

SYNOPSIS

    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::Class->meta->get_attribute("field")->has_filter;  # true

DESCRIPTION

MooseX::AttributeFilter::Trait::Attribute is a trait for Moose::Meta::Attribute. MooseX::AttributeFilter automatically applies it to all attributes, but it acts as no-op if attribute does not use filter option.

Methods

filter

Returns the value of the filter option. This may be a string (method name) or coderef or undef.

has_filter

Boolean.

bypass_filter_method_check

Boolean.

    has attr => (
        is      => 'rw',
        filter  => 'my_filter_method',
        bypass_filter_method_check => 1,
    );

Can be used to make MooseX::AttributeFilter::Trait::Attribute not throw error message in case of my_filter_method method not exists. (Will still throw error if is called and cannot find method.) Used for edge cases like when filter method will be provided by AUTOLOAD or later added by trait.

SEE ALSO

MooseX::AttributeFilter.

LICENSE

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.

AUTHOR

KITTEN <kitten@cpan.org>

https://metacpan.org/author/KITTEN

https://github.com/icklekitten

<3