Fix the logic somewhat
[catagits/Catalyst-Runtime.git] / t / lib / TestAppCustomContainer / NoSugarContainer.pm
index b8dd626..cfb5e36 100644 (file)
@@ -8,57 +8,39 @@ extends 'Catalyst::IOC::Container';
 sub BUILD {
     my $self = shift;
 
-    $self->get_sub_container('component')->add_service(
-        Catalyst::IOC::ConstructorInjection->new(
-            name         => 'model_Bar',
-            class        => 'TestAppCustomContainer::Model::Bar',
-            dependencies => [
-                depends_on( '/application_name' ),
-                depends_on( '/config' ),
-                depends_on( '/model/Foo' ),
-            ],
-        )
-    );
     $self->get_sub_container('model')->add_service(
-        Catalyst::IOC::BlockInjection->new(
-            name         => 'Bar',
-            dependencies => [
-                depends_on( '/model/Foo' ),
-                depends_on( '/component/model_Bar' ),
-            ],
-            block => sub {
-                my $s        = shift;
-                my $foo      = $s->param('Foo');
-                my $instance = $s->param('model_Bar');
-                return $instance;
+        Catalyst::IOC::ConstructorInjection->new(
+            name             => 'Bar',
+            lifecycle        => 'Singleton',
+            class            => 'TestAppCustomContainer::Model::Bar',
+            dependencies     => {
+                application_name => depends_on( '/application_name' ),
+                config => depends_on( '/config' ),
+                foo => depends_on('/model/Foo'),
             },
         )
     );
 
-    $self->get_sub_container('component')->add_service(
-        Catalyst::IOC::ConstructorInjection->new(
-            name         => 'model_Baz',
-            class        => 'TestAppCustomContainer::Model::Baz',
-            lifecycle    => '+Catalyst::IOC::LifeCycle::Request',
-            dependencies => [
-                depends_on( '/application_name' ),
-                depends_on( '/config' ),
-                depends_on( '/model/Foo' ),
-            ],
-        )
-    );
     $self->get_sub_container('model')->add_service(
+        # FIXME - i think it should be a ConstructorInjection
+        # but only BlockInjection gets ctx parameter
         Catalyst::IOC::BlockInjection->new(
             name         => 'Baz',
+            lifecycle    => '+Catalyst::IOC::LifeCycle::Request',
             dependencies => [
-                depends_on( '/model/Foo' ),
-                depends_on( '/component/model_Baz' ),
+                Bread::Board::Dependency->new(
+                    service_name => 'foo',
+                    service_path => 'Foo',
+
+                    # FIXME - same as above
+                    service_params => {
+                        ctx => +{},
+                        accept_context_args => [ +{} ],
+                    },
+                ),
             ],
             block => sub {
-                my $s        = shift;
-                my $foo      = $s->param('Foo');
-                my $instance = $s->param('model_Baz');
-                return $instance;
+                TestAppCustomContainer::Model::Baz->new(foo => shift->param('foo'));
             },
         )
     );
@@ -78,7 +60,7 @@ sub BUILD {
         Catalyst::IOC::ConstructorInjection->new(
             name         => 'model_Fnar',
             lifecycle    => 'Singleton',
-            class        => 'My::External::Class',
+            class        => 'TestAppCustomContainer::External::Class',
             dependencies => [
                 depends_on( '/application_name' ),
                 depends_on( '/config' ),