Path::Dispatcher::Rule::Under(3pm)

Path::Dispatcher::Rule::Under3pm

Rules under a predicate

Usage

    my $ticket = Path::Dispatcher::Rule::Tokens->new(
        tokens => [ 'ticket' ],
        prefix => 1,
    );
    my $create = Path::Dispatcher::Rule::Tokens->new(
        tokens => [ 'create' ],
        block  => sub { create_ticket() },
    );
    my $delete = Path::Dispatcher::Rule::Tokens->new(
        tokens => [ 'delete', qr/^\d+$/ ],
        block  => sub { delete_ticket(shift->pos(2)) },
    );
    my $rule = Path::Dispatcher::Rule::Under->new(
        predicate => $ticket,
        rules     => [ $create, $delete ],
    );
    $rule->match("ticket create");
    $rule->match("ticket delete 3");

Version

version 1.08

Overview

Rules of this class have two-phase matching: if the predicate is matched, then the contained rules are matched. The benefit of this is less repetition of the predicate, both in terms of code and in matching it.

Attributes

predicate

A rule (which must match prefixes) whose match determines whether the contained rules are considered. The leftover path of the predicate is used as the path for the contained rules.

rules

A list of rules that will be try to be matched only if the predicate is matched.

Support

Bugs may be submitted through the RT bug tracker <https://rt.cpan.org/Public/Dist/Display.html?Name=Path-Dispatcher> (or [email protected] <mailto:[email protected]>).

Releases

7 releases since Debian 6.0 (Squeeze); the text changed 3 times.

  1. 6.0
  2. 7
  3. 8–9
  4. 11–13

Author

Shawn M Moore, "<sartak at bestpractical.com>"

From libpath-dispatcher-perl 1.08-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.