lib/Mail/Decency/Core/Child.pm

filter: Statementstmt 70.8% 17 / 24 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 4 / 8 Podpod 100% 3 / 3 totaltotal 64.8% 24 / 37 CC 2 SCAR 8.9
CC
2
Cov
65%
get_handlers
6.0
__ANON__
2.0
handle
2.0
CRAP 2.4
« lib/Mail/Decency/ContentFilter/Razor.pm ↑ Summary lib/Mail/Decency.pm »
1 package Mail::Decency::Core::Child;
2  
3 16 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 16 extends 'Mail::Decency::Core::Meta';
5  
6 16 ▶use version 0.74; our $VERSION = qv( "v0.1.4" );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 16 ▶use Scalar::Util qw/ weaken /;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 Mail::Decency::Policy::Core
13  
14 =head1 SYNOPSIS
15  
16 use Mail::DecencyPolicy;
17 use Mail::DecencyPolicy::AWL;
18
19 my $policy = Mail::DecencyPolicy->new( {
20 config => '/etc/pdp/config'
21 } );
22
23 my $server = POE::Component::Server::Postfix->new(
24 port => 12345,
25 host => '127.0.0.1',
26 filter => 'Plain',
27 handler => $policy->get_handler()
28 );
29 POE::Kernel->run;
30  
31 =head1 DESCRIPTION
32  
33 Base class for all policies
34  
35 Postfix:DecencyPolicy is a bunch of policy servers which c
36  
37 Base class for all decency policy handlers.
38  
39 =cut
40  
41  
42 16 ▶use overload '""' => \&get_name;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 =head1 CLASS ATTRIBUTES
45  
46 =cut
47  
48 16 has name => ( is => 'rw', isa => 'Str', required => 1 );
49 16 has server => ( is => 'rw', isa => 'Mail::Decency::Core::Server', required => 1, weak_ref => 1 );
50  
51  
52 =head1 METHODS
53  
54 =head2 get_handlers
55  
56 Return handlers as a single sub-ref
57  
58 =cut
59  
60 0 ▶sub get_handlers {
Subroutine get_handlers: not called CC=2 SCAR=17.9
Pod documented
61 0 my ( $self ) = @_;
62
63 # check wheter having config!
64 0 ▶ die "No config has been set\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_config 0 0 0
65 unless $self->has_config;
66
67 0 weaken( my $self_weak = $self );
68 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
69 0 return $self_weak->handle( @_ );
70 0 };
71 }
72  
73  
74 =head2 handle
75  
76  
77 =cut
78  
79 0 ▶sub handle {
Subroutine handle: not called CC=1 SCAR=6.9
Pod documented
80 0 die "Handler has to be defined for child module ". ( ref( shift ) ). "\n";
81 }
82  
83  
84  
85 =head2 get_name
86  
87 Used for the overloaded string context
88  
89 =cut
90  
91 0 ▶sub get_name {
Subroutine get_name: not called CC=1 SCAR=6.9
Pod documented
92 0 return shift->name;
93 }
94  
95 =head1 AUTHOR
96  
97 Ulrich Kautz <uk@fortrabbit.de>
98  
99 =head1 COPYRIGHT
100  
101 Copyright (c) 2010 the L</AUTHOR> as listed above
102  
103 =head1 LICENCSE
104  
105 This library is free software and may be distributed under the same terms as perl itself.
106  
107 =cut
108  
109 16 1;
« lib/Mail/Decency/ContentFilter/Razor.pm ↑ Summary lib/Mail/Decency.pm »