| 1 | package Mail::MtPolicyd::Plugin; | ||||||||||
| 2 | |||||||||||
| 3 | 18 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 18 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 18 | our $VERSION = '2.01'; # VERSION | |||||||||
| 7 | # ABSTRACT: a base class for plugins | ||||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | 18 | has 'name' => ( is => 'rw', isa => 'Str', required => 1 ); | |||||||||
| 11 | 18 | has 'log_level' => ( is => 'ro', isa => 'Int', default => 4 ); | |||||||||
| 12 | 18 | has 'vhost_name' => ( is => 'ro', isa => 'Maybe[Str]' ); | |||||||||
| 13 | |||||||||||
| 14 | 18 | has 'on_error' => ( is => 'ro', isa => 'Maybe[Str]' ); | |||||||||
| 15 | |||||||||||
| 16 | |||||||||||
| 17 | sub run { | ||||||||||
| 18 | 0 | ▶ | my ( $self, $r ) = @_; | ||||||||
|
Subroutine
run: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 19 | 0 | die('plugin did not implement run method!'); | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | sub log { | ||||||||||
| 23 | 137 | ▶ | my ($self, $r, $msg) = @_; | ||||||||
|
Subroutine
log: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||
| 24 | 137 | ▶ | if( defined $self->vhost_name ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 0 | $msg = $self->vhost_name.': '.$msg; | |||||||||
| 26 | } | ||||||||||
| 27 | 137 | $r->log($self->log_level, $msg); | |||||||||
| 28 | |||||||||||
| 29 | 137 | return; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | sub init { | ||||||||||
| 33 | 4 | ▶ | return; | ||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | sub cron { | ||||||||||
| 37 | 0 | ▶ | return; | ||||||||
|
Subroutine
cron: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 18 | __PACKAGE__->meta->make_immutable; | |||||||||
| 41 | |||||||||||
| 42 | 18 | 1; | |||||||||
| 43 | |||||||||||
| 44 | __END__ | ||||||||||
| 45 | |||||||||||
| 46 | =pod | ||||||||||
| 47 | |||||||||||
| 48 | =encoding UTF-8 | ||||||||||
| 49 | |||||||||||
| 50 | =head1 NAME | ||||||||||
| 51 | |||||||||||
| 52 | Mail::MtPolicyd::Plugin - a base class for plugins | ||||||||||
| 53 | |||||||||||
| 54 | =head1 VERSION | ||||||||||
| 55 | |||||||||||
| 56 | version 2.01 | ||||||||||
| 57 | |||||||||||
| 58 | =head1 ATTRIBUTES | ||||||||||
| 59 | |||||||||||
| 60 | =head2 name | ||||||||||
| 61 | |||||||||||
| 62 | Contains a string with the name of this plugin as specified in the configuration. | ||||||||||
| 63 | |||||||||||
| 64 | =head2 log_level (default: 4) | ||||||||||
| 65 | |||||||||||
| 66 | The log_level used when the plugin calls $self->log( $r, $msg ). | ||||||||||
| 67 | |||||||||||
| 68 | =head1 METHODS | ||||||||||
| 69 | |||||||||||
| 70 | =head2 run( $r ) | ||||||||||
| 71 | |||||||||||
| 72 | This method has be implemented by the plugin which inherits from this base class. | ||||||||||
| 73 | |||||||||||
| 74 | =head2 log( $r, $msg ) | ||||||||||
| 75 | |||||||||||
| 76 | This method could be used by the plugin to log something. | ||||||||||
| 77 | |||||||||||
| 78 | Since this is mostly for debugging the default is to log plugin specific | ||||||||||
| 79 | messages with log_level=4. (see log_level attribute) | ||||||||||
| 80 | |||||||||||
| 81 | =head1 AUTHOR | ||||||||||
| 82 | |||||||||||
| 83 | Markus Benning <ich@markusbenning.de> | ||||||||||
| 84 | |||||||||||
| 85 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 86 | |||||||||||
| 87 | This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>. | ||||||||||
| 88 | |||||||||||
| 89 | This is free software, licensed under: | ||||||||||
| 90 | |||||||||||
| 91 | The GNU General Public License, Version 2, June 1991 | ||||||||||
| 92 | |||||||||||
| 93 | =cut | ||||||||||