d8f3bde7f1ad586904fdb8ba6297872ebb648db7
[catagits/Catalyst-Runtime.git] / t / lib / TestAppCustomContainerNoSugar / Container.pm
1 package TestAppCustomContainerNoSugar::Container;
2 use Moose;
3
4 extends 'Catalyst::IOC::Container';
5
6 sub BUILD {
7     my $self = shift;
8     $self->get_sub_container('component')->add_service(
9         Catalyst::IOC::ConstructorInjection->new(
10             name         => 'model_Baz',
11             class        => 'TestAppCustomContainerNoSugar::Model::Baz',
12             lifecycle    => 'InstancePerContext',
13             dependencies => [
14                 depends_on( '/application_name' ),
15                 depends_on( '/config' ),
16                 depends_on( '/model/Foo' ),
17             ],
18         )
19     );
20     $self->get_sub_container('model')->add_service(
21         Catalyst::IOC::BlockInjection->new(
22             name         => 'Baz',
23             dependencies => [
24                 depends_on( '/model/Foo' ),
25                 depends_on( '/component/model_Baz' ),
26             ],
27             block => sub {
28                 my $s        = shift;
29                 my $foo      = $s->param('Foo');
30                 my $instance = $s->param('model_Baz');
31                 return $instance;
32             },
33         )
34     );
35 }
36
37 1;