Skip to content

Commit

Permalink
deprecated Mojolicious::Routes->controller_base_class in favor of Moj…
Browse files Browse the repository at this point in the history
…olicious::Routes->base_classes
  • Loading branch information
kraih committed Mar 20, 2012
1 parent 20c18f6 commit 34d45f7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
2 changes: 2 additions & 0 deletions Changes
@@ -1,6 +1,8 @@
This file documents the revision history for Perl extension Mojolicious.

2.64 2012-03-21 00:00:00
- Deprecated Mojolicious::Routes->controller_base_class in favor of
Mojolicious::Routes->base_classes.
- Improved documentation.

2.63 2012-03-20 00:00:00
Expand Down
37 changes: 25 additions & 12 deletions lib/Mojolicious/Routes.pm
@@ -1,16 +1,17 @@
package Mojolicious::Routes;
use Mojo::Base 'Mojolicious::Routes::Route';

use List::Util 'first';
use Mojo::Cache;
use Mojo::Loader;
use Mojo::Util 'camelize';
use Mojolicious::Routes::Match;
use Scalar::Util 'weaken';

has 'namespace';
has cache => sub { Mojo::Cache->new };
has base_classes => sub { [qw/Mojolicious::Controller Mojo/] };
has cache => sub { Mojo::Cache->new };
has [qw/conditions shortcuts/] => sub { {} };
has controller_base_class => 'Mojolicious::Controller';
has hidden => sub { [qw/new attr has/] };

sub add_condition {
Expand All @@ -33,6 +34,18 @@ sub auto_render {
$c->render or ($stash->{'mojo.routed'} or $c->render_not_found);
}

# DEPRECATED in Leaf Fluttering In Wind!
sub controller_base_class {
warn <<EOF;
Mojolicious::Routes->controller_base_class is DEPRECATED in favor of
Mojolicious::Routes->base_classes!
EOF
my $self = shift;
return $self->base_classes->[0] unless @_;
$self->base_classes->[0] = shift;
return $self;
}

sub dispatch {
my ($self, $c) = @_;

Expand Down Expand Up @@ -201,8 +214,8 @@ sub _load_class {
die $e;
}

# Check for controller and application
return unless $app->isa($self->controller_base_class) || $app->isa('Mojo');
# Check base classes
return unless first { $app->isa($_) } @{$self->base_classes};
return ++$self->{loaded}->{$app};
}

Expand Down Expand Up @@ -293,6 +306,14 @@ L<Mojolicious::Guides::Routing> for more.
L<Mojolicious::Routes> inherits all attributes from
L<Mojolicious::Routes::Route> and implements the following new ones.
=head2 C<base_classes>
my $classes = $r->base_classes;
$r = $r->base_classes(['Mojolicious::Controller']);
Base classes used to identify controllers, defaults to
L<Mojolicious::Controller> and L<Mojo>.
=head2 C<cache>
my $cache = $r->cache;
Expand All @@ -307,14 +328,6 @@ Routing cache, defaults to a L<Mojo::Cache> object.
Contains all available conditions.
=head2 C<controller_base_class>
my $base = $r->controller_base_class;
$r = $r->controller_base_class('Mojolicious::Controller');
Base class used to identify controllers, defaults to
L<Mojolicious::Controller>.
=head2 C<hidden>
my $hidden = $r->hidden;
Expand Down
4 changes: 2 additions & 2 deletions t/pod_coverage.t
Expand Up @@ -9,8 +9,8 @@ plan skip_all => 'set TEST_POD to enable this test (developer only!)'

# DEPRECATED in Leaf Fluttering In Wind!
my @leaf = (
qw/default_static_class default_template_class dictionary max_redirects/,
qw/prepare_ioloop root unsubscribe x_forwarded_for/
qw/controller_base_class default_static_class default_template_class/,
qw/dictionary max_redirects prepare_ioloop root unsubscribe x_forwarded_for/
);

# "Marge, I'm going to miss you so much. And it's not just the sex.
Expand Down

0 comments on commit 34d45f7

Please sign in to comment.