Erwan Lemonnier > Hook-Filter > Hook::Filter::Rule

Download:
Hook-Filter-0.10.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  1
View/Report Bugs
Module Version: 0.04   Source  

NAME ^

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

DESCRIPTION ^

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::.

SYNOPSIS ^

    use Hook::Filter::Rule;

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

INTERFACE ^

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:

subname
arg
from

DIAGNOSTICS ^

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.

BUGS AND LIMITATIONS ^

See Hook::Filter

SEE ALSO ^

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

VERSION ^

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

AUTHOR ^

Erwan Lemonnier <erwan@cpan.org>

LICENSE ^

See Hook::Filter.

syntax highlighting: