Path::Dispatcher::Role::Rules - "has a list of rules"


Path-Dispatcher documentation Contained in the Path-Dispatcher distribution.

Index


Code Index:

NAME

Top

Path::Dispatcher::Role::Rules - "has a list of rules"

DESCRIPTION

Top

Classes that compose this role get the following things:

ATTRIBUTES

Top

_rules

METHODS

Top

rules

add_rule


Path-Dispatcher documentation Contained in the Path-Dispatcher distribution.

package Path::Dispatcher::Role::Rules;
use Any::Moose '::Role';

has _rules => (
    is       => 'ro',
    isa      => 'ArrayRef',
    init_arg => 'rules',
    default  => sub { [] },
);

sub add_rule {
    my $self = shift;

    $_->isa('Path::Dispatcher::Rule')
        or confess "$_ is not a Path::Dispatcher::Rule"
            for @_;

    push @{ $self->{_rules} }, @_;
}

sub unshift_rule {
    my $self = shift;

    $_->isa('Path::Dispatcher::Rule')
        or confess "$_ is not a Path::Dispatcher::Rule"
            for @_;

    unshift @{ $self->{_rules} }, @_;
}

sub rules { @{ shift->{_rules} } }

no Any::Moose;

1;

__END__