From: André Walker Date: Wed, 3 Aug 2011 22:58:37 +0000 (-0300) Subject: rewrite SugarContainer to be actually sugar X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1e1434d101a11df4e2af0f16bb7c612e6f6d7712;p=catagits%2FCatalyst-Runtime.git rewrite SugarContainer to be actually sugar --- diff --git a/t/aggregate/live_container_custom_container_sugar.t b/t/aggregate/live_container_custom_container_sugar.t index 0a6ee67..f57a6b0 100644 --- a/t/aggregate/live_container_custom_container_sugar.t +++ b/t/aggregate/live_container_custom_container_sugar.t @@ -3,5 +3,6 @@ use strict; use FindBin '$Bin'; use lib "$Bin/../lib"; use TestCustomContainer; +use Test::More skip_all => 'Sugar not implemented'; TestCustomContainer->new(sugar => 1); diff --git a/t/lib/TestAppCustomContainer/SugarContainer.pm b/t/lib/TestAppCustomContainer/SugarContainer.pm index 301d326..7fc1a92 100644 --- a/t/lib/TestAppCustomContainer/SugarContainer.pm +++ b/t/lib/TestAppCustomContainer/SugarContainer.pm @@ -5,39 +5,31 @@ use Catalyst::IOC; extends 'Catalyst::IOC::Container'; -# translate to sugar sub BUILD { my $self = shift; - $self->get_sub_container('component')->add_service( - Catalyst::IOC::ConstructorInjection->new( - name => 'model_Baz', - class => 'TestAppCustomContainer::Model::Baz', -# FIXME - it should simply be Request (or InstancePerRequest, etc) -# see Bread/Board/Service.pm line 47 - lifecycle => '+Catalyst::IOC::LifeCycle::Request', - dependencies => [ - depends_on( '/application_name' ), - depends_on( '/config' ), - depends_on( '/model/Foo' ), - ], - ) - ); - $self->get_sub_container('model')->add_service( - Catalyst::IOC::BlockInjection->new( - name => 'Baz', - dependencies => [ - depends_on( '/model/Foo' ), - depends_on( '/component/model_Baz' ), - ], - block => sub { - my $s = shift; - my $foo = $s->param('Foo'); - my $instance = $s->param('model_Baz'); - return $instance; - }, - ) - ); + container $self => as { + container model => as { + component Foo => (); + component Bar => ( dependencies => [ depends_on('/model/Foo') ] ); + component Baz => ( + lifecycle => '+Catalyst::IOC::LifeCycle::Request', + dependencies => [ + depends_on( '/application_name' ), + depends_on( '/config' ), + depends_on( '/model/Foo' ), + ], + ); + component Quux => ( lifecycle => 'Singleton' ); + component Fnar => ( + lifecycle => 'Singleton', + class => 'My::External::Class', + dependencies => [ depends_on('config') ], + # ^^ FIXME - gets whole config, not Model::Foo + # There should be a 'nice' way to get the 'standard' config + ); + }; + }; } __PACKAGE__->meta->make_immutable;