From: Tomas Doran Date: Tue, 2 Aug 2011 20:51:22 +0000 (+0100) Subject: remove make_single_default X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=8697f11669be14108294ead3f14bbf4054fa7210 remove make_single_default --- diff --git a/TODO b/TODO index 19b74d8..3910d0f 100644 --- a/TODO +++ b/TODO @@ -145,14 +145,6 @@ after BUILD => sub { ### To polish off / t0m review - - + $class->container->get_sub_container('model')->make_single_default; - + $class->container->get_sub_container('view')->make_single_default; - - locate_components service vs setup_components method - - can we be more lazy? - - should setup_components be a service that things like the ->component lookup - can depend on? - +Same as L, but for controllers. The difference is +that there is no ACCEPT_CONTEXT for controllers. ^^ This is wrong!! diff --git a/lib/Catalyst/IOC/Container.pm b/lib/Catalyst/IOC/Container.pm index 825f6f1..a1ca69a 100644 --- a/lib/Catalyst/IOC/Container.pm +++ b/lib/Catalyst/IOC/Container.pm @@ -472,9 +472,6 @@ sub setup_components { unless $comps{$component}; } } - - $self->get_sub_container('model')->make_single_default; - $self->get_sub_container('view')->make_single_default; } sub _fix_syntax { diff --git a/lib/Catalyst/IOC/SubContainer.pm b/lib/Catalyst/IOC/SubContainer.pm index 4870bf0..ccbf007 100644 --- a/lib/Catalyst/IOC/SubContainer.pm +++ b/lib/Catalyst/IOC/SubContainer.pm @@ -7,10 +7,19 @@ extends 'Bread::Board::Container'; has default_component => ( isa => 'Str|Undef', is => 'ro', - required => 0, - writer => '_set_default_component', + builder => '_build_default_component', + lazy => 1, ); +sub _build_default_componentt { + my ( $self ) = @_; + + my @complist = $self->get_service_list; + + scalar @complist == 1 ? $complist[0] : undef; +} + + sub get_component { my ( $self, $name, @args ) = @_; @@ -30,17 +39,6 @@ sub get_component_regexp { return @result; } -# FIXME - is this sub ok? -# is the name ok too? -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__