From: André Walker Date: Wed, 14 Dec 2011 01:40:12 +0000 (-0200) Subject: created two methods for building new services: home and root. neither is ready yet X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=10a10c42feaf9a229f6501cea313f01be441ee24 created two methods for building new services: home and root. neither is ready yet --- diff --git a/lib/Catalyst/IOC/Container.pm b/lib/Catalyst/IOC/Container.pm index 8102262..a7b5c46 100644 --- a/lib/Catalyst/IOC/Container.pm +++ b/lib/Catalyst/IOC/Container.pm @@ -151,6 +151,44 @@ sub build_component_subcontainer { ); } +sub build_home_service { + my $self = shift; + + return Bread::Board::BlockInjection->new( + lifecycle => 'Singleton', + name => 'home', + block => sub { + my $self = shift; + my $class = $self->param('application_name'); + + if ( my $env = Catalyst::Utils::env_value( $class, 'HOME' ) ) { + $home = $env; + } + + $home ||= Catalyst::Utils::home($class); + + return $home; + }, + dependencies => [ depends_on('application_name') ], + ); +} + +# FIXME: very ambiguous - maybe root_dir? +sub build_root_service { + my $self = shift; + + return Bread::Board::BlockInjection->new( + lifecycle => 'Singleton', + name => 'root', + block => sub { + my $self = shift; + + return Path::Class::Dir->new( $self->param('home') )->subdir('root'); + }, + dependencies => [ depends_on('home') ], + ); +} + sub build_application_name_service { my $self = shift;