we can reuse the same test app for container with and without sugar
[catagits/Catalyst-Runtime.git] / t / lib / TestAppCustomContainer / NoSugarContainer.pm
1 package TestAppCustomContainer::NoSugarContainer;
2 use Moose;
3 use namespace::autoclean;
4 use Catalyst::IOC;
5
6 extends 'Catalyst::IOC::Container';
7
8 sub BUILD {
9     my $self = shift;
10     $self->get_sub_container('component')->add_service(
11         Catalyst::IOC::ConstructorInjection->new(
12             name         => 'model_Baz',
13             class        => 'TestAppCustomContainer::Model::Baz',
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
39 __PACKAGE__->meta->make_immutable;
40
41 1;