X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FIOC%2FContainer.pm;h=a7b5c46a113a162b45a0f1cb3e67680202ed0726;hp=8102262faf8c1777413db304aebe19979fb882b7;hb=10a10c42feaf9a229f6501cea313f01be441ee24;hpb=cc9a49cfb7842ecaf1ffc096ba702a3c7355cbb3 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;