add_component only needs one arg now
[catagits/Catalyst-Runtime.git] / lib / Catalyst.pm
index 710ce29..720beb1 100644 (file)
@@ -597,8 +597,9 @@ sub model {
     my ( $c, $name, @args ) = @_;
 
     if (ref $c && !$name) {
+        my $current_instance = $c->stash->{current_model_instance};
         return $current_instance
-            if my $current_instance = $c->stash->{current_model_instance};
+            if $current_instance;
 
         $name = $c->stash->{current_model};
     }
@@ -632,8 +633,9 @@ sub view {
     my ( $c, $name, @args ) = @_;
 
     if (ref $c && !$name) {
+        my $current_instance = $c->stash->{current_view_instance};
         return $current_instance
-            if my $current_instance = $c->stash->{current_view_instance};
+            if $current_instance;
 
         $name = $c->stash->{current_view};
     }
@@ -1444,9 +1446,7 @@ sub components {
     my $container = $class->container;
 
     if ( $comps ) {
-        $container->add_component(
-            $_, $class
-        ) for keys %$comps;
+        $container->add_component( $_ ) for keys %$comps;
     }
 
     return $container->get_all_components();
@@ -2288,7 +2288,7 @@ sub setup_config {
 
     my $container_class = Class::MOP::load_first_existing_class(@container_classes);
 
-    my $container = $container_class->new( %args, name => "$class" );
+    my $container = $container_class->new( %args, application_name => "$class", name => "$class" );
     $class->container($container);
 
     my $config = $container->resolve(service => 'config');
@@ -2315,16 +2315,30 @@ The C<setup_components> config option is passed to both of the above methods.
 =cut
 
 sub setup_components {
-    my $class = shift;
-    # FIXME - I believe I shouldn't be handing $class over
-    # Just don't know how to solve this.
-    return $class->container->setup_components( $class );
+    shift->container->setup_components();
 }
 
+=head2 locate_components
+
+=cut
+
 # FIXME - removed locate_components
 # don't people mess with this method directly?
 # what to do with that?
 
+sub locate_components {
+    my $class = shift;
+
+    $class->log->warn('The locate_components method has been deprecated.');
+    $class->log->warn('Please read Catalyst::IOC::Container documentation to');
+    $class->log->warn('update your application.');
+
+    # XXX think about ditching this sort entirely
+    return sort { length $a <=> length $b }
+        @{ $class->container->resolve( service => 'locate_components' ) };
+}
+
+
 =head2 $c->setup_dispatcher
 
 Sets up dispatcher.