rewrite SugarContainer to be actually 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',
b18a77bd 14
15# FIXME - it should simply be Request (or InstancePerRequest, etc)
16# see Bread/Board/Service.pm line 47
17 lifecycle => '+Catalyst::IOC::LifeCycle::Request',
3ef84846 18 dependencies => [
19 depends_on( '/application_name' ),
20 depends_on( '/config' ),
21 depends_on( '/model/Foo' ),
22 ],
23 )
24 );
25 $self->get_sub_container('model')->add_service(
26 Catalyst::IOC::BlockInjection->new(
27 name => 'Baz',
28 dependencies => [
29 depends_on( '/model/Foo' ),
30 depends_on( '/component/model_Baz' ),
31 ],
32 block => sub {
33 my $s = shift;
34 my $foo = $s->param('Foo');
35 my $instance = $s->param('model_Baz');
36 return $instance;
37 },
38 )
39 );
40}
41
88cea23c 42__PACKAGE__->meta->make_immutable;
43
3ef84846 441;