we can reuse the same test app for container with and without sugar
[catagits/Catalyst-Runtime.git] / t / lib / TestAppCustomContainer / NoSugarContainer.pm
CommitLineData
88cea23c 1package TestAppCustomContainer::NoSugarContainer;
3ef84846 2use Moose;
88cea23c 3use namespace::autoclean;
4use Catalyst::IOC;
3ef84846 5
6extends 'Catalyst::IOC::Container';
7
8sub BUILD {
9 my $self = shift;
10 $self->get_sub_container('component')->add_service(
11 Catalyst::IOC::ConstructorInjection->new(
12 name => 'model_Baz',
88cea23c 13 class => 'TestAppCustomContainer::Model::Baz',
3ef84846 14 lifecycle => 'InstancePerContext',
15 dependencies => [
16 depends_on( '/application_name' ),
17 depends_on( '/config' ),
18 depends_on( '/model/Foo' ),
19 ],
20 )
21 );
22 $self->get_sub_container('model')->add_service(
23 Catalyst::IOC::BlockInjection->new(
24 name => 'Baz',
25 dependencies => [
26 depends_on( '/model/Foo' ),
27 depends_on( '/component/model_Baz' ),
28 ],
29 block => sub {
30 my $s = shift;
31 my $foo = $s->param('Foo');
32 my $instance = $s->param('model_Baz');
33 return $instance;
34 },
35 )
36 );
37}
38
88cea23c 39__PACKAGE__->meta->make_immutable;
40
3ef84846 411;