From: André Walker Date: Fri, 29 Jun 2012 21:10:06 +0000 (-0300) Subject: renaming application_name -> catalyst_application X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=96c9f5d4c9cebf815970a5ea94b90ad693ebaa93;hp=6ac0784b4442b46abae68c76318c2189221e725d renaming application_name -> catalyst_application --- diff --git a/lib/Catalyst/IOC.pm b/lib/Catalyst/IOC.pm index 4b25e1b..19e2c47 100644 --- a/lib/Catalyst/IOC.pm +++ b/lib/Catalyst/IOC.pm @@ -61,7 +61,7 @@ sub component ($;%) { } $args{dependencies} ||= {}; - $args{dependencies}{application_name} = depends_on( '/application_name' ); + $args{dependencies}{catalyst_application} = depends_on( '/catalyst_application' ); my $lifecycle = $args{lifecycle} || 'Singleton'; $args{lifecycle} = grep( m/^$lifecycle$/, qw/COMPONENTSingleton Request/ ) @@ -72,7 +72,7 @@ sub component ($;%) { # FIXME - check $args{type} here! my $component_name = join '::', ( - $current_container->resolve(service => '/application_name'), + $current_container->resolve(service => '/catalyst_application'), ucfirst($current_container->name), $name ); diff --git a/lib/Catalyst/IOC/ConstructorInjection.pm b/lib/Catalyst/IOC/ConstructorInjection.pm index bed9355..dce5def 100644 --- a/lib/Catalyst/IOC/ConstructorInjection.pm +++ b/lib/Catalyst/IOC/ConstructorInjection.pm @@ -44,12 +44,7 @@ sub get { my %config = (%{ $self->config || {} }, %{ $params }); $self->_clear_config; - # FIXME - Is depending on the application name to pass into constructors here a good idea? - # This makes app/ctx split harder I think.. Need to think more here, but I think - # we want to pass the application in as a parameter when building the service - # rather than depending on the app name, so that later, when the app becomes an instance - # then it'll get passed in, and components can stash themselves 'per app instance' - my $app_name = $self->param('application_name'); + my $app = $self->param('catalyst_application'); # Stash catalyst_component_name in the config here, so that custom COMPONENT # methods also pass it. @@ -62,7 +57,7 @@ sub get { my $instance; try { - $instance = $component->COMPONENT( $app_name, \%config ); + $instance = $component->COMPONENT( $app, \%config ); } catch { Catalyst::Exception->throw( diff --git a/lib/Catalyst/IOC/Container.pm b/lib/Catalyst/IOC/Container.pm index a5c4492..f8a9e97 100644 --- a/lib/Catalyst/IOC/Container.pm +++ b/lib/Catalyst/IOC/Container.pm @@ -60,7 +60,7 @@ sub BUILD { substitutions file driver - application_name + catalyst_application prefix extensions path @@ -153,7 +153,7 @@ sub build_home_service { name => 'home', block => sub { my $self = shift; - my $class = $self->param('application_name'); + my $class = $self->param('catalyst_application'); my $home; if ( my $env = Catalyst::Utils::env_value( $class, 'HOME' ) ) { @@ -163,7 +163,7 @@ sub build_home_service { $home ||= Catalyst::Utils::home($class); return $home; }, - dependencies => [ depends_on('application_name') ], + dependencies => [ depends_on('catalyst_application') ], ); } @@ -182,10 +182,10 @@ sub build_root_dir_service { ); } -sub build_application_name_service { +sub build_catalyst_application_service { my $self = shift; - return Bread::Board::Literal->new( name => 'application_name', value => $self->name ); + return Bread::Board::Literal->new( name => 'catalyst_application', value => $self->name ); } sub build_driver_service { @@ -225,9 +225,9 @@ sub build_prefix_service { lifecycle => 'Singleton', name => 'prefix', block => sub { - return Catalyst::Utils::appprefix( shift->param('application_name') ); + return Catalyst::Utils::appprefix( shift->param('catalyst_application') ); }, - dependencies => [ depends_on('application_name') ], + dependencies => [ depends_on('catalyst_application') ], ); } @@ -240,11 +240,11 @@ sub build_path_service { block => sub { my $s = shift; - return Catalyst::Utils::env_value( $s->param('application_name'), 'CONFIG' ) + return Catalyst::Utils::env_value( $s->param('catalyst_application'), 'CONFIG' ) || $s->param('file') - || $s->param('application_name')->path_to( $s->param('prefix') ); + || $s->param('catalyst_application')->path_to( $s->param('prefix') ); }, - dependencies => [ depends_on('file'), depends_on('application_name'), depends_on('prefix') ], + dependencies => [ depends_on('file'), depends_on('catalyst_application'), depends_on('prefix') ], ); } @@ -260,13 +260,13 @@ sub build_config_service { my $v = Data::Visitor::Callback->new( plain_value => sub { return unless defined $_; - return $self->_config_substitutions( $s->param('application_name'), $s->param('substitutions'), $_ ); + return $self->_config_substitutions( $s->param('catalyst_application'), $s->param('substitutions'), $_ ); } ); $v->visit( $s->param('raw_config') ); }, - dependencies => [ depends_on('application_name'), depends_on('raw_config'), depends_on('substitutions') ], + dependencies => [ depends_on('catalyst_application'), depends_on('raw_config'), depends_on('substitutions') ], ); } @@ -358,7 +358,7 @@ sub build_class_config_service { name => 'class_config', block => sub { my $s = shift; - my $app = $s->param('application_name'); + my $app = $s->param('catalyst_application'); # Container might be called outside Catalyst context return {} unless Class::MOP::is_class_loaded($app); @@ -366,7 +366,7 @@ sub build_class_config_service { # config might not have been defined return $app->config || {}; }, - dependencies => [ depends_on('application_name') ], + dependencies => [ depends_on('catalyst_application') ], ); } @@ -443,11 +443,11 @@ sub build_config_local_suffix_service { name => 'config_local_suffix', block => sub { my $s = shift; - my $suffix = Catalyst::Utils::env_value( $s->param('application_name'), 'CONFIG_LOCAL_SUFFIX' ) || $self->config_local_suffix; + my $suffix = Catalyst::Utils::env_value( $s->param('catalyst_application'), 'CONFIG_LOCAL_SUFFIX' ) || $self->config_local_suffix; return $suffix; }, - dependencies => [ depends_on('application_name') ], + dependencies => [ depends_on('catalyst_application') ], ); } @@ -459,7 +459,7 @@ sub build_locate_components_service { name => 'locate_components', block => sub { my $s = shift; - my $class = $s->param('application_name'); + my $class = $s->param('catalyst_application'); my $config = $s->param('config')->{ setup_components }; Catalyst::Exception->throw( @@ -477,13 +477,13 @@ sub build_locate_components_service { return [ $locator->plugins ]; }, - dependencies => [ depends_on('application_name'), depends_on('config') ], + dependencies => [ depends_on('catalyst_application'), depends_on('config') ], ); } sub setup_components { my $self = shift; - my $class = $self->resolve( service => 'application_name' ); + my $class = $self->resolve( service => 'catalyst_application' ); my @comps = @{ $self->resolve( service => 'locate_components' ) }; my %comps = map { $_ => 1 } @comps; my $deprecatedcatalyst_component_names = 0; @@ -712,7 +712,7 @@ sub add_component { class => $component, lifecycle => 'Singleton', dependencies => [ - depends_on( '/application_name' ), + depends_on( '/catalyst_application' ), ], ), ); @@ -801,7 +801,7 @@ Same as L, but for controllers. =head1 Methods for Building Services -=head2 build_application_name_service +=head2 build_catalyst_application_service Name of the application (such as MyApp). diff --git a/t/lib/TestAppCustomContainer/NoSugarContainer.pm b/t/lib/TestAppCustomContainer/NoSugarContainer.pm index e1439d6..d345aad 100644 --- a/t/lib/TestAppCustomContainer/NoSugarContainer.pm +++ b/t/lib/TestAppCustomContainer/NoSugarContainer.pm @@ -15,7 +15,7 @@ sub BUILD { class => 'TestAppCustomContainer::Model::SingletonLifeCycle', catalyst_component_name => 'TestAppCustomContainer::Model::SingletonLifeCycle', dependencies => { - application_name => depends_on( '/application_name' ), + catalyst_application => depends_on( '/catalyst_application' ), }, ) ); @@ -27,7 +27,7 @@ sub BUILD { class => 'TestAppCustomContainer::Model::RequestLifeCycle', catalyst_component_name => 'TestAppCustomContainer::Model::RequestLifeCycle', dependencies => { - application_name => depends_on( '/application_name' ), + catalyst_application => depends_on( '/catalyst_application' ), }, ) ); @@ -38,7 +38,7 @@ sub BUILD { # class => 'TestAppCustomContainer::Model::DependsOnDefaultSetup', # catalyst_component_name => 'TestAppCustomContainer::Model::DependsOnDefaultSetup', # dependencies => { -# application_name => depends_on( '/application_name' ), +# catalyst_application => depends_on( '/catalyst_application' ), # # FIXME - this is what is blowing up everything: # # DefaultSetup needs the context. It's not getting it here! # foo => depends_on('/model/DefaultSetup'), @@ -65,7 +65,7 @@ sub BUILD { # lifecycle => 'Singleton', # class => 'TestAppCustomContainer::External::Class', # dependencies => [ -# depends_on( '/application_name' ), +# depends_on( '/catalyst_application' ), # ], # config => $fnar_config, # )