| 1 | package Antispam::Toolkit::Role::URIChecker; | ||
| 2 | BEGIN { | ||
| 3 | $Antispam::Toolkit::Role::URIChecker::VERSION = '0.08'; | ||
| 4 | } | ||
| 5 | |||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | use namespace::autoclean; | ||
| 9 | |||
| 10 | use Antispam::Toolkit::Types qw( NonEmptyStr ); | ||
| 11 | |||
| 12 | use Moose::Role; | ||
| 13 | use MooseX::Params::Validate qw( validated_hash ); | ||
| 14 | |||
| 15 | requires 'check_uri'; | ||
| 16 | |||
| 17 | around check_uri => sub { | ||
| 18 | my $orig = shift; | ||
| 19 | my $self = shift; | ||
| 20 | my %p = validated_hash( | ||
| 21 | \@_, | ||
| 22 | uri => { isa => NonEmptyStr }, | ||
| 23 | ); | ||
| 24 | |||
| 25 | $self->$orig(%p); | ||
| 26 | }; | ||
| 27 | |||
| 28 | 1; | ||
| 29 | |||
| 30 | # ABSTRACT: A role for classes which check whether a uri is spam | ||
| 31 | |||
| 32 | |||
| 33 | |||
| 34 | =pod | ||
| 35 | |||
| 36 | =head1 NAME | ||
| 37 | |||
| 38 | Antispam::Toolkit::Role::URIChecker - A role for classes which check whether a uri is spam | ||
| 39 | |||
| 40 | =head1 VERSION | ||
| 41 | |||
| 42 | version 0.08 | ||
| 43 | |||
| 44 | =head1 SYNOPSIS | ||
| 45 | |||
| 46 | package MyURIChecker; | ||
| 47 | |||
| 48 | use Moose; | ||
| 49 | |||
| 50 | with 'Antispam::Toolkit::Role::URIChecker'; | ||
| 51 | |||
| 52 | sub check_uri { ... } | ||
| 53 | |||
| 54 | =head1 DESCRIPTION | ||
| 55 | |||
| 56 | This role specifies an interface for classes which check whether a specific | ||
| 57 | uri is spam. | ||
| 58 | |||
| 59 | =head1 REQUIRED METHODS | ||
| 60 | |||
| 61 | Classes which consume this method must provide one method: | ||
| 62 | |||
| 63 | =head2 $checker->check_uri( uri => ... ) | ||
| 64 | |||
| 65 | This method implements the actual spam checking for a uri. The uri will be | ||
| 66 | passed as a named parameter. | ||
| 67 | |||
| 68 | =head1 METHODS | ||
| 69 | |||
| 70 | This role provides an around modifier for the C<< $checker->check_uri() >> | ||
| 71 | method. The modifier does validation on all the parameters, so there's no need | ||
| 72 | to implement this in the class itself. | ||
| 73 | |||
| 74 | =head1 BUGS | ||
| 75 | |||
| 76 | See L<Antispam::Toolkit> for bug reporting details. | ||
| 77 | |||
| 78 | =head1 AUTHOR | ||
| 79 | |||
| 80 | Dave Rolsky <autarch@urth.org> | ||
| 81 | |||
| 82 | =head1 COPYRIGHT AND LICENSE | ||
| 83 | |||
| 84 | This software is Copyright (c) 2011 by Dave Rolsky. | ||
| 85 | |||
| 86 | This is free software, licensed under: | ||
| 87 | |||
| 88 | The Artistic License 2.0 (GPL Compatible) | ||
| 89 | |||
| 90 | =cut | ||
| 91 | |||
| 92 | |||
| 93 | __END__ |