From: André Walker Date: Wed, 2 May 2012 02:11:45 +0000 (-0300) Subject: added the app to the container when the app is built X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=8287cb1c9c2cd36b97ccbb75fc2c2b6bb32a7857 added the app to the container when the app is built --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index fad4c90..1b4c69f 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -142,6 +142,15 @@ sub MODIFY_CODE_ATTRIBUTES { ); } +sub BUILD { + my $self = shift; + my $class = ref $self; + + Catalyst::Exception->throw("You can't run the application before $class" . "->setup") + unless $class->setup_finished; + + $self->container->_set_application($self); +} sub _application { $_[0] } diff --git a/lib/Catalyst/IOC/Container.pm b/lib/Catalyst/IOC/Container.pm index e5609b3..d152144 100644 --- a/lib/Catalyst/IOC/Container.pm +++ b/lib/Catalyst/IOC/Container.pm @@ -45,6 +45,8 @@ has application => ( is => 'ro', isa => 'Catalyst|Str', lazy => 1, + weak_ref => 1, + writer => '_set_application', default => sub { shift->application_name }, );