Skip to content

Commit

Permalink
BSD Style じゃないほうがスキ
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.coderepos.org/share/lang/perl/HTTPx-Dispatcher/trunk@10430 d0d07461-0603-4401-acd4-de1884942a52
  • Loading branch information
tokuhirom committed Apr 25, 2008
1 parent c4e9a4c commit c27ba63
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions lib/HTTPx/Dispatcher.pm
Expand Up @@ -13,33 +13,30 @@ our @EXPORT = qw/connect match uri_for/;

my $rules;

sub connect
{
my $pkg = caller(0);
sub connect {
my $pkg = caller(0);
my @args = @_;

push @{ $rules->{$pkg} } , HTTPx::Dispatcher::Rule->new(@args);
push @{ $rules->{$pkg} }, HTTPx::Dispatcher::Rule->new(@args);
}

sub match
{
my ($class, $req) = @_;
sub match {
my ( $class, $req ) = @_;
croak "request required" unless blessed $req;

for my $rule (@{ $rules->{$class} }) {
if (my $result = $rule->match($req)) {
for my $rule ( @{ $rules->{$class} } ) {
if ( my $result = $rule->match($req) ) {
return $result;
}
}
return; # no match.
return; # no match.
}

sub uri_for
{
my ($class, @args) = @_;
sub uri_for {
my ( $class, @args ) = @_;

for my $rule ( @{ $rules->{$class} } ) {
if (my $result = $rule->uri_for( @args ) ) {
if ( my $result = $rule->uri_for(@args) ) {
return $result;
}
}
Expand Down

0 comments on commit c27ba63

Please sign in to comment.