X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FController.pm;h=f33fda5e1e8df14fc2d0f455bd12341239cc68ee;hb=a7caa492274a184c77ec32af58b2dc6db7295650;hp=d31b704666be8dbab83e858a34ca9a537cd707a4;hpb=6323fda2e7ace0fc0aa06305c674957cedc6d025;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Controller.pm b/lib/Catalyst/Controller.pm index d31b704..f33fda5 100644 --- a/lib/Catalyst/Controller.pm +++ b/lib/Catalyst/Controller.pm @@ -1,43 +1,13 @@ package Catalyst::Controller; -use Moose; -use Class::MOP (); -#use MooseX::ClassAttribute; +use strict; +use base qw/Catalyst::Component Catalyst::AttrContainer/; + use Catalyst::Exception; use Catalyst::Utils; use Class::Inspector; use NEXT; -#extends qw/Catalyst::Component Catalyst::AttrContainer/; -use base qw/Catalyst::Component Catalyst::AttrContainer/; - -# class_has _dispatch_steps => -# ( -# is => 'rw', -# isa => 'ArrayRef', -# required => 1, -# default => sub{ [qw/_BEGIN _AUTO _ACTION/] }, -# ); - -# class_has _action_class => -# ( -# is => 'rw', -# isa => 'ClassName', -# required => 1, -# default => sub{ 'Catalyst::Action' }, -# ); - -__PACKAGE__->mk_classdata('_dispatch_steps'); -__PACKAGE__->mk_classdata('_action_class'); - -__PACKAGE__->_action_class('Catalyst::Action'); -__PACKAGE__->_dispatch_steps([qw/_BEGIN _AUTO _ACTION/]); - - -has _application => ( is => 'rw' ); -### _app as alias -*_app = *_application; - =head1 NAME Catalyst::Controller - Catalyst Controller base class @@ -61,17 +31,15 @@ for more info about how Catalyst dispatches to actions. =cut -# just emulating old behavior. we could probably do this -# via BUILD later or pass $app as application => $app -around new => sub { - my $orig = shift; - my $self = shift; - my $app = $_[0]; - my $new = $self->$orig(@_); - $new->_application( $app ); - return $new; -}; +__PACKAGE__->mk_classdata($_) for qw/_dispatch_steps _action_class/; +__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 ) = @_; @@ -120,6 +88,15 @@ sub _END : Private { return !@{ $c->error }; } +sub new { + my $self = shift; + my $app = $_[0]; + my $new = $self->NEXT::new(@_); + $new->_application( $app ); + return $new; +} + + sub action_for { my ( $self, $name ) = @_; my $app = ($self->isa('Catalyst') ? $self : $self->_application); @@ -154,12 +131,9 @@ sub register_actions { my $class = ref $self || $self; my $namespace = $self->action_namespace($c); my %methods; - { - my $meth_map = $class->meta->get_method_map; - @methods{values %$meth_map} = (keys %$meth_map); - } + $methods{ $self->can($_) } = $_ + for @{ Class::Inspector->methods($class) || [] }; - #Moose TODO: something tells me that roles could kill the directly code below # Advanced inheritance support for plugins and the like my @action_cache; { @@ -204,11 +178,9 @@ sub create_action { ? $args{attributes}{ActionClass}[0] : $self->_action_class); - #can we replace with a single call to Class::MOP::load_class() ? - #unless ( Class::Inspector->loaded($class) ) { - # require Class::Inspector->filename($class); - #} - Class::MOP::load_class($class); + unless ( Class::Inspector->loaded($class) ) { + require Class::Inspector->filename($class); + } return $class->new( \%args ); }