__PACKAGE__->_dispatch_steps( [qw/_BEGIN _AUTO _ACTION/] );
__PACKAGE__->_action_class('Catalyst::Action');
+__PACKAGE__->mk_accessors( qw/_application/ );
+
+### _app as alias
+*_app = *_application;
+
sub _DISPATCH : Private {
my ( $self, $c ) = @_;
}
sub new {
- my $self = shift;
- my $app = $_[0];
- my $new = $self->NEXT::new(@_);
- $new->{application} = $app;
- return $new;
+ my $self = shift;
+ my $app = $_[0];
+ my $new = $self->NEXT::new(@_);
+ $new->_application( $app );
+ return $new;
}
=head1 NAME
=head2 $class->new($app, @args)
Proxies through to NEXT::new and stashes the application instance as
-$self->{application}.
+$self->_application.
=head2 $self->action_for('name')
sub action_for {
my ( $self, $name ) = @_;
- my $app = ($self->isa('Catalyst') ? $self : $self->{application});
+ my $app = ($self->isa('Catalyst') ? $self : $self->_application);
return $app->dispatcher->get_action($name, $self->action_namespace);
}
sub action_namespace {
my ( $self, $c ) = @_;
unless ( $c ) {
- $c = ($self->isa('Catalyst') ? $self : $self->{application});
+ $c = ($self->isa('Catalyst') ? $self : $self->_application);
}
my $hash = (ref $self ? $self : $self->config); # hate app-is-class
return $hash->{namespace} if exists $hash->{namespace};
sub path_prefix {
my ( $self, $c ) = @_;
unless ( $c ) {
- $c = ($self->isa('Catalyst') ? $self : $self->{application});
+ $c = ($self->isa('Catalyst') ? $self : $self->_application);
}
my $hash = (ref $self ? $self : $self->config); # hate app-is-class
return $hash->{path} if exists $hash->{path};
return ( 'ActionClass', $value );
}
+=head2 $self->_application
+
+=head2 $self->_app
+
+Returns the application instance stored by C<new()>
+
=head1 SEE ALSO
L<Catalyst>, L<Catalyst::Controller>.