File Coverage

blib/lib/Antispam/Toolkit/Result.pm
Criterion Covered Total %
statement 19 20 95.0
branch n/a
condition n/a
subroutine 7 8 87.5
pod n/a
total 26 28 92.8


line stmt bran cond sub pod time code
1             package Antispam::Toolkit::Result;
2             BEGIN {
3 1     1   820 $Antispam::Toolkit::Result::VERSION = '0.08';
4             }
5              
6 1     1   7 use strict;
  1         2  
  1         34  
7 1     1   5 use warnings;
  1         2  
  1         46  
8              
9 1     1   489 use Antispam::Toolkit::Types qw( Details NonNegativeNum );
  1         4  
  1         9  
10              
11 1     1   1712 use overload 'bool' => sub { $_[0]->score() > 0 };
  1     0   3  
  1         13  
  0         0  
12              
13 1     1   64 use Moose;
  1         34  
  1         8  
14 1     1   7786 use MooseX::StrictConstructor;
  1         23998  
  1         7  
15              
16             has score => (
17             is => 'ro',
18             isa => NonNegativeNum,
19             required => 1,
20             );
21              
22             has _details => (
23             traits => ['Array'],
24             is => 'bare',
25             isa => Details,
26             coerce => 1,
27             default => sub { [] },
28             init_arg => 'details',
29             handles => {
30             details => 'elements',
31             },
32             );
33              
34             __PACKAGE__->meta()->make_immutable();
35              
36             1;
37              
38             # ABSTRACT: Represents the result of a spam check
39              
40              
41             __END__
42             =pod
43              
44             =head1 NAME
45              
46             Antispam::Toolkit::Result - Represents the result of a spam check
47              
48             =head1 VERSION
49              
50             version 0.08
51              
52             =head1 SYNOPSIS
53              
54             return Antispam::Toolkit::Result->new(
55             score => 2,
56             details => [
57             q{The user's ip address was found in a list of known spammers},
58             q{The user's email address was found in a list of known bad email addresses},
59             ],
60             );
61              
62             =head1 DESCRIPTION
63              
64             This class represents the result of a spam check. It consists of a score and
65             details associated with that score.
66              
67             The score is simple a non-negative number. The details are optional, and
68             should be provided as an array reference of strings, each of which describes
69             some aspect of the spam check.
70              
71             =head1 METHODS
72              
73             This class provides the following methods:
74              
75             =head2 Antispam::Toolkit::Result->new( ... )
76              
77             This method constructs a new result object. It accepts the following
78             attributes:
79              
80             =over 4
81              
82             =item * score
83              
84             This attribute is required, and must be a non-negative number.
85              
86             =item * details
87              
88             This attribute can be either a single non-empty string or an array reference
89             of non-empty strings. It is not required.
90              
91             =back
92              
93             =head2 $result->score()
94              
95             Returns the score for the result.
96              
97             =head2 $result->details()
98              
99             Returns I<a list> of strings. This list may be empty.
100              
101             =head1 OVERLOADING
102              
103             This object overloads the boolean operator. If the score is greater than 0, it
104             overloads as true, otherwise it overloads as false.
105              
106             =head1 BUGS
107              
108             See L<Antispam::Toolkit> for bug reporting details.
109              
110             =head1 AUTHOR
111              
112             Dave Rolsky <autarch@urth.org>
113              
114             =head1 COPYRIGHT AND LICENSE
115              
116             This software is Copyright (c) 2011 by Dave Rolsky.
117              
118             This is free software, licensed under:
119              
120             The Artistic License 2.0 (GPL Compatible)
121              
122             =cut
123