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