added fixme's
[catagits/Catalyst-Runtime.git] / t / lib / TestAppCustomContainer / NoSugarContainer.pm
index 13721b8..ecf423d 100644 (file)
@@ -11,11 +11,12 @@ sub BUILD {
     $self->get_sub_container('component')->add_service(
         Catalyst::IOC::ConstructorInjection->new(
             name         => 'model_Bar',
+            lifecycle    => 'Singleton',
             class        => 'TestAppCustomContainer::Model::Bar',
             dependencies => [
                 depends_on( '/application_name' ),
                 depends_on( '/config' ),
-                depends_on( '/model/Foo' ),
+                depends_on( 'model_Foo' ),
             ],
         )
     );
@@ -23,14 +24,26 @@ sub BUILD {
         Catalyst::IOC::BlockInjection->new(
             name         => 'Bar',
             dependencies => [
-                depends_on( '/model/Foo' ),
+                Bread::Board::Dependency->new(
+                    service_path => 'Foo',
+
+                    # FIXME - obviously this is a mistake
+                    # what to do with ctx here?
+                    # I have no way to get $s here, do I?
+                    service_params => {
+                        ctx => +{},
+                        accept_context_args => [ +{} ],
+                    },
+                ),
                 depends_on( '/component/model_Bar' ),
             ],
             block => sub {
-                my $s        = shift;
-                my $foo      = $s->param('Foo');
-                my $instance = $s->param('model_Bar');
-                return $instance;
+                my $s   = shift;
+
+                my $foo = $s->param('Foo');
+                $foo->inc_bar_got_it;
+
+                return $s->param('model_Bar');
             },
         )
     );
@@ -39,15 +52,14 @@ sub BUILD {
         Catalyst::IOC::ConstructorInjection->new(
             name         => 'model_Baz',
             class        => 'TestAppCustomContainer::Model::Baz',
-# t0m - I'm fine with this - sugar can just s/Request/+Catalyst::IOC::LifeCycle::Request/
-#       Also, 'Request' is fine as a name for a lifecycle IMO.
-# FIXME - it should simply be Request (or InstancePerRequest, etc)
-# see Bread/Board/Service.pm line 47
-            lifecycle    => '+Catalyst::IOC::LifeCycle::Request',
+            lifecycle    => 'Singleton',
+
+            # while it doesn't fully work
+            #lifecycle    => '+Catalyst::IOC::LifeCycle::Request',
             dependencies => [
                 depends_on( '/application_name' ),
                 depends_on( '/config' ),
-                depends_on( '/model/Foo' ),
+                depends_on( 'model_Foo' ),
             ],
         )
     );
@@ -55,14 +67,24 @@ sub BUILD {
         Catalyst::IOC::BlockInjection->new(
             name         => 'Baz',
             dependencies => [
-                depends_on( '/model/Foo' ),
+                Bread::Board::Dependency->new(
+                    service_path => 'Foo',
+
+                    # FIXME - same as above
+                    service_params => {
+                        ctx => +{},
+                        accept_context_args => [ +{} ],
+                    },
+                ),
                 depends_on( '/component/model_Baz' ),
             ],
             block => sub {
-                my $s        = shift;
-                my $foo      = $s->param('Foo');
-                my $instance = $s->param('model_Baz');
-                return $instance;
+                my $s   = shift;
+
+                my $foo = $s->param('Foo');
+                $foo->inc_baz_got_it;
+
+                return $s->param('model_Baz');
             },
         )
     );
@@ -70,10 +92,6 @@ sub BUILD {
     $self->get_sub_container('model')->add_service(
         Catalyst::IOC::BlockInjection->new(
             name         => 'Quux',
-
-# FIXME - it should probably be our
-# Catalyst::IOC::LifeCycle::Singleton
-# t0m - I think normal Singleton is fine here, it's per app lifetime.
             lifecycle    => 'Singleton',
             dependencies => [
                 depends_on( '/component/model_Quux' ),
@@ -86,7 +104,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' ),