From: André Walker Date: Wed, 3 Aug 2011 23:09:33 +0000 (-0300) Subject: completed NoSugarContainer to match SugarContainer X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f831deb1b1b468c3c884061f84c05b48722ab93c;p=catagits%2FCatalyst-Runtime.git completed NoSugarContainer to match SugarContainer --- diff --git a/t/lib/TestAppCustomContainer/NoSugarContainer.pm b/t/lib/TestAppCustomContainer/NoSugarContainer.pm index 2314e50..6abc3d6 100644 --- a/t/lib/TestAppCustomContainer/NoSugarContainer.pm +++ b/t/lib/TestAppCustomContainer/NoSugarContainer.pm @@ -7,6 +7,34 @@ extends 'Catalyst::IOC::Container'; sub BUILD { my $self = shift; + + $self->get_sub_container('component')->add_service( + Catalyst::IOC::ConstructorInjection->new( + name => 'model_Bar', + class => 'TestAppCustomContainer::Model::Bar', + dependencies => [ + depends_on( '/application_name' ), + depends_on( '/config' ), + depends_on( '/model/Foo' ), + ], + ) + ); + $self->get_sub_container('model')->add_service( + Catalyst::IOC::BlockInjection->new( + name => 'Bar', + dependencies => [ + depends_on( '/model/Foo' ), + depends_on( '/component/model_Bar' ), + ], + block => sub { + my $s = shift; + my $foo = $s->param('Foo'); + my $instance = $s->param('model_Bar'); + return $instance; + }, + ) + ); + $self->get_sub_container('component')->add_service( Catalyst::IOC::ConstructorInjection->new( name => 'model_Baz', @@ -37,6 +65,43 @@ sub BUILD { }, ) ); + + $self->get_sub_container('model')->add_service( + Catalyst::IOC::BlockInjection->new( + name => 'Quux', + +# FIXME - it should probably be our +# Catalyst::IOC::LifeCycle::Singleton + lifecycle => 'Singleton', + dependencies => [ + depends_on( '/component/model_Quux' ), + ], + block => sub { shift->param('model_Bar') }, + ) + ); + + $self->get_sub_container('component')->add_service( + Catalyst::IOC::ConstructorInjection->new( + name => 'model_Fnar', + lifecycle => 'Singleton', + class => 'My::External::Class', + dependencies => [ + depends_on( '/application_name' ), + depends_on( '/config' ), + ], + ) + ); + $self->get_sub_container('model')->add_service( + Catalyst::IOC::BlockInjection->new( + name => 'model_Fnar', + lifecycle => 'Singleton', + dependencies => [ + depends_on( '/config' ), + depends_on( '/component/model_Fnar' ), + ], + block => sub { shift->param('model_Fnar') }, + ) + ); } __PACKAGE__->meta->make_immutable;