reverting back to when tests pass. applying changes one by one to find what failed
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Controller.pm
index d31b704..ab77e21 100644 (file)
@@ -1,43 +1,13 @@
 package Catalyst::Controller;
 
-use Moose;
-use Class::MOP ();
-#use MooseX::ClassAttribute;
+use strict;
+use base qw/Catalyst::Component Catalyst::AttrContainer Class::Accessor::Fast/;
+
 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
@@ -47,9 +17,9 @@ Catalyst::Controller - Catalyst Controller base class
   package MyApp::Controller::Search
   use base qw/Catalyst::Controller/;
 
-  sub foo : Local {
+  sub foo : Local { 
     my ($self,$c,@args) = @_;
-    ...
+    ... 
   } # Dispatches to /search/foo
 
 =head1 DESCRIPTION
@@ -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,12 +178,10 @@ 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 );
 }
 
@@ -338,7 +310,7 @@ controller name. For instance controller 'MyApp::Controller::Foo::Bar'
 will be bound to 'foo/bar'. The default Root controller is an example
 of setting namespace to '' (the null string).
 
-=head2 path
+=head2 path 
 
 Sets 'path_prefix', as described below.