
Hook::Filter::Rule - A hook filter rule

A filter rule is a string containing a perl expression that evaluates to either true or false.
A rule may contain calls to functions exported by any module under Hook::Filter::Plugins::.

use Hook::Filter::Rule;
my $rule = Hook::Filter::Rule->new("1");
if ($rule->eval) {
print "just now, the rule [".$rule->rule."] is true\n";
}

my $r = new($rule)Return a new Hook::Filter::Rule created from the string $rule. $rule is a valid line of perl code that should return either true or false when eval-ed. It can contain calls to any of the functions exported by the plugin modules located under Hook::Filter::Plugins::.
$r->eval()Eval this rule. Return 0 if the rule eval-ed to false. Return 1 if the rule eval-ed to true, or if the rule died/croaked.
If the rule dies/croaks/confesses while being eval-ed, a perl warning is thrown and the rule is assumed to return true (fail-safe). The warning contains details about the error message, the rule itself and where it comes from (as specified with source()).
$r->source($message)Specify the origin of this rule. If the rule was parsed from a rule file, $message should be the path to this file. This is used in the warning message emitted when a rule dies during eval().
$r->rule()Return the rule's string ($rule in new()).
The following functions are exported by the default plugin library Hook::Filter::Plugin::Library:

use Hook::Filter::Rule croaks if a plugin module tries to export a function name that is already exported by an other plugin.
Hook::Filter::Rule->new($rule) croaks if $rule is not a scalar.
$rule->eval() will emit a perl warning if the rule dies when eval-ed.
$rule->source($text) croaks if $text is not a scalar.
See Hook::Filter

See Hook::Filter, Hook::Filter::RulePool, Hook::Filter::Hooker, Hook::Filter::Plugins::Library.

$Id: Rule.pm,v 1.7 2008/06/09 21:04:08 erwan_lemonnier Exp $

Erwan Lemonnier <erwan@cpan.org>

See Hook::Filter.