Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 22, 2011
1 parent 815065f commit 0006f74
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/Command.pm
Expand Up @@ -306,7 +306,7 @@ sub _command {
return unless ref $e;
die $e;
}
return unless $module->can('new') && $module->isa('Mojo::Command');
return unless $module->isa('Mojo::Command');

return $module;
}
Expand Down
9 changes: 4 additions & 5 deletions lib/Mojolicious/Lite.pm
Expand Up @@ -23,22 +23,21 @@ sub import {
unless $ENV{MOJO_HOME};

# Initialize app
no strict 'refs';
my $caller = caller;
push @{"${caller}::ISA"}, $class;
my $app = $class->new;

# Initialize routes
my $routes = $app->routes;
$routes->namespace('');

# Prepare exports
my $caller = caller;
no strict 'refs';
no warnings 'redefine';

# Default static and template class
$app->static->default_static_class($caller);
$app->renderer->default_template_class($caller);

# Export
no warnings 'redefine';
my $root = $routes;
*{"${caller}::new"} = *{"${caller}::app"} = sub {$app};
*{"${caller}::any"} = sub { $routes->any(@_) };
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Plugins.pm
Expand Up @@ -84,7 +84,7 @@ sub _load {
}

# Module is a plugin
return unless $module->can('new') && $module->can('register');
return unless $module->isa('Mojolicious::Plugin');
return 1;
}

Expand Down
37 changes: 19 additions & 18 deletions lib/Mojolicious/Routes.pm
Expand Up @@ -402,20 +402,36 @@ sub _dispatch_controller {
return $e;
}

# Loaded
# Don't try again in the future
$self->{loaded}->{$app}++;
}

# Dispatch
return unless $app->isa($self->controller_base_class) || $app->isa('Mojo');
my $continue;
my $success = eval {
$app = $app->new($c) unless ref $app;

# Handler
if ($app->isa('Mojo')) {

# Connect routes
if ($app->can('routes')) {
my $r = $app->routes;
unless ($r->parent) {
$r->parent($c->match->endpoint);
weaken $r->{parent};
}
}

$app->handler($c);
}

# Action
if ($method && $app->isa($self->controller_base_class)) {
my $stash = $c->stash;
elsif ($method) {

# Call action
my $stash = $c->stash;
if ($app->can($method)) {
$stash->{'mojo.routed'} = 1 unless $staging;
$continue = $app->$method;
Expand All @@ -434,21 +450,6 @@ sub _dispatch_controller {
@{$stash}{keys %$new} = values %$new;
}

# Handler
elsif ($app->isa('Mojo')) {

# Connect routes
if ($app->can('routes')) {
my $r = $app->routes;
unless ($r->parent) {
$r->parent($c->match->endpoint);
weaken $r->{parent};
}
}

$app->handler($c);
}

1;
};

Expand Down

0 comments on commit 0006f74

Please sign in to comment.