Antispam-Toolkit
view release on metacpan or search on metacpan
lib/Antispam/Toolkit/Role/ContentChecker.pm view on Meta::CPAN
package Antispam::Toolkit::Role::ContentChecker;
BEGIN {
$Antispam::Toolkit::Role::ContentChecker::VERSION = '0.08';
}
use strict;
use warnings;
use namespace::autoclean;
use Antispam::Toolkit::Types qw( ArrayRef NonEmptyStr );
use List::AllUtils qw( first );
use Moose::Role;
use MooseX::Params::Validate qw( validated_hash );
requires qw( check_content _build_accepted_content_types );
has _accepted_content_types => (
is => 'bare',
isa => ArrayRef [NonEmptyStr],
init_arg => undef,
lazy => 1,
builder => '_build_accepted_content_types',
);
around check_content => sub {
my $orig = shift;
my $self = shift;
my %p = validated_hash(
\@_,
content_type => { isa => NonEmptyStr },
content => { isa => NonEmptyStr },
);
return
unless first { $_ eq $p{content_type} }
@{ $self->_accepted_content_types() };
return $self->$orig(@_);
};
1;
# ABSTRACT: A role for classes which check whether a piece of content is spam
=pod
=head1 NAME
Antispam::Toolkit::Role::ContentChecker - A role for classes which check whether a piece of content is spam
=head1 VERSION
version 0.08
=head1 SYNOPSIS
package MyContentChecker;
use Moose;
with 'Antispam::Toolkit::Role::ContentChecker';
sub check_content { ... }
=head1 DESCRIPTION
( run in 0.722 second using v1.01-cache-2.11-cpan-f56aa216473 )