switched MyApp for the actual app name in setup_config
[catagits/Catalyst-Runtime.git] / lib / Catalyst.pm
index 6b43cc3..cf63b77 100644 (file)
@@ -2455,8 +2455,7 @@ sub setup_config {
 
     my %args = %{ $class->config || {} };
 
-# FIXME: what is this 'MyApp' doing here?
-    my @container_classes = qw/MyApp::Container Catalyst::Container/;
+    my @container_classes = ( (ref $class || $class) . '::Container', 'Catalyst::Container');
     unshift @container_classes, delete $args{container_class} if exists $args{container_class};
 
     my $container_class = Class::MOP::load_first_existing_class(@container_classes);
@@ -2547,9 +2546,9 @@ sub _get_component_type {
     my @parts     = split /::/, $component;
 
     for (@parts) {
-        return 'controller' if /c|controller/i;
-        return 'model'      if /m|model/i;
-        return 'view'       if /v|view/i;
+        return 'controller' if /^c|controller$/i;
+        return 'model'      if /^m|model$/i;
+        return 'view'       if /^v|view$/i;
     }
 }
 
@@ -2623,8 +2622,7 @@ sub setup_component {
             message => qq/Couldn't instantiate component "$component", "$error"/
         );
     }
-
-    unless (blessed $instance) {
+    elsif (!blessed $instance) {
         my $metaclass = Moose::Util::find_meta($component);
         my $method_meta = $metaclass->find_method_by_name('COMPONENT');
         my $component_method_from = $method_meta->associated_metaclass->name;
@@ -2634,6 +2632,7 @@ sub setup_component {
             qq/Couldn't instantiate component "$component", COMPONENT() method (from $component_method_from) didn't return an object-like value (value was $value)./
         );
     }
+
     return $instance;
 }