broke expand_modules, setup_component became a method
[catagits/Catalyst-Runtime.git] / lib / Catalyst / IOC / SubContainer.pm
index 068f379..afa8e3f 100644 (file)
@@ -5,6 +5,13 @@ use Catalyst::IOC::BlockInjection;
 
 extends 'Bread::Board::Container';
 
+has default_component => (
+    isa => 'Str|Undef',
+    is  => 'ro',
+    required => 0,
+    writer   => '_set_default_component',
+);
+
 sub get_component {
     my ( $self, $name, @args ) = @_;
 
@@ -24,6 +31,16 @@ sub get_component_regexp {
     return @result;
 }
 
+# FIXME: not the best name for a sub
+sub make_single_default {
+    my ( $self ) = @_;
+
+    my @complist = $self->get_service_list;
+
+    $self->_set_default_component( shift @complist )
+        if !$self->default_component && scalar @complist == 1;
+}
+
 1;
 
 __END__
@@ -40,6 +57,8 @@ Catalyst::IOC::SubContainer - Container for models, controllers and views
 
 =head2 get_component_regexp
 
+=head2 make_single_default
+
 =head1 AUTHORS
 
 Catalyst Contributors, see Catalyst.pm