On Sat, 10 Sep 2016 13:09:55 +0000 (UTC)
Pedro David Marco wrote:

> Hi there...
> i am not an expert OO developer so i am somehow flying blind in here
> and need your help please Basically i want to write my own plugin and
> i have some repeated calculations in each and every plugin method
> that i would like to reduce to just one, 

This is usually done in whichever happens to be the first "eval" rule to
be called for each message. A plugin object isn't created per message,
so its constructor isn't the place to do anything with message data. 


For example check_bayes() is evaluated for every BAYES_* rule,
and you have:


  sub check_bayes {
    my ($self, $pms, $fulltext, $min, $max) = @_;
    ...

    if (!exists ($pms->{bayes_score})) {
      my $timer = $self->{main}->time_method("check_bayes");
      $pms->{bayes_score} = $self->scan($pms, $pms->{msg});
    }
    ...

pms is a per message data structure.


See also how _check_dkim_signature() is being called in various places
in Plugin/DKIM.pm.



Reply via email to