Switch to catalyst_component_name
Tomas Doran [Mon, 17 Aug 2009 23:14:38 +0000 (23:14 +0000)]
Changes
lib/Catalyst.pm
lib/Catalyst/Action.pm
lib/Catalyst/Component.pm
lib/Catalyst/Controller.pm
t/aggregate/live_component_controller_anon.t
t/lib/TestApp/Action/TestMyAction.pm
t/lib/TestApp/Controller/Anon.pm

diff --git a/Changes b/Changes
index f253221..d70f917 100644 (file)
--- a/Changes
+++ b/Changes
@@ -34,7 +34,7 @@
          expand_component_module (rjbs)
        - Allow Components to return anon classed from their COMPONENT method
          correctly, and have action registration work on Controllers returned
-         as such by adding a _component_name accessor for all components
+         as such by adding a catalyst_component_name accessor for all components
          which returns the component instance's name to be used when building
          actions etc.
        - Adding X-Forwarded-Port to allow the frontend proxy to dictate the
index 8dfc175..e30d38e 100644 (file)
@@ -2154,10 +2154,10 @@ sub setup_components {
     my @comps = sort { length $a <=> length $b }
                 $class->locate_components($config);
 
-    my $deprecated_component_names = grep { /::[CMV]::/ } @comps;
+    my $deprecatedcatalyst_component_names = grep { /::[CMV]::/ } @comps;
     $class->log->warn(qq{Your application is using the deprecated ::[MVC]:: type naming scheme.\n}.
         qq{Please switch your class names to ::Model::, ::View:: and ::Controller: as appropriate.\n}
-    ) if $deprecated_component_names;
+    ) if $deprecatedcatalyst_component_names;
 
     for my $component ( @comps ) {
 
@@ -2251,10 +2251,10 @@ sub setup_component {
 
     my $suffix = Catalyst::Utils::class2classsuffix( $component );
     my $config = $class->config->{ $suffix } || {};
-    # Stash _component_name in the config here, so that custom COMPONENT
+    # Stash catalyst_component_name in the config here, so that custom COMPONENT
     # methods also pass it. local to avoid pointlessly shitting in config
     # for the debug screen, as $component is already the key name.
-    local $config->{_component_name} = $component;
+    local $config->{catalyst_component_name} = $component;
 
     my $instance = eval { $component->COMPONENT( $class, $config ); };
 
index af65452..87b37fd 100644 (file)
@@ -104,7 +104,7 @@ and so on. This determines how the action is dispatched to.
 =head2 class
 
 Returns the name of the component where this action is defined.
-Derived by calling the L<Catalyst::Component/_component_name|_component_name>
+Derived by calling the L<Catalyst::Component/catalyst_component_name|catalyst_component_name>
 method on each component.
 
 =head2 code
index 6367a7d..870418c 100644 (file)
@@ -60,15 +60,15 @@ component loader with config() support and a process() method placeholder.
 __PACKAGE__->mk_classdata('_plugins');
 __PACKAGE__->mk_classdata('_config');
 
-has _component_name => ( is => 'ro' ); # Cannot be required => 1 as context
+has catalyst_component_name => ( is => 'ro' ); # Cannot be required => 1 as context
                                        # class @ISA component - HATE
 # Make accessor callable as a class method, as we need to call setup_actions
 # on the application class, which we don't have an instance of, ewwwww
 # Also, naughty modules like Catalyst::View::JSON try to write to _everything_,
 # so spit a warning, ignore that (and try to do the right thing anyway) here..
-around _component_name => sub {
+around catalyst_component_name => sub {
     my ($orig, $self) = (shift, shift);
-    Carp::cluck("Tried to write to the _component_name accessor - is your component broken or just mad? (Write ignored - using default value.)") if scalar @_;
+    Carp::cluck("Tried to write to the catalyst_component_name accessor - is your component broken or just mad? (Write ignored - using default value.)") if scalar @_;
     blessed($self) ? $self->$orig() || blessed($self) : $self;
 };
 
index 3c313c7..972b6a3 100644 (file)
@@ -158,7 +158,7 @@ around action_namespace => sub {
         }
     }
 
-    my $namespace = Catalyst::Utils::class2prefix($self->_component_name, $case_s) || '';
+    my $namespace = Catalyst::Utils::class2prefix($self->catalyst_component_name, $case_s) || '';
     $self->$orig($namespace) if ref($self);
     return $namespace;
 };
@@ -209,7 +209,7 @@ sub register_actions {
 
 sub register_action_methods {
     my ( $self, $c, @methods ) = @_;
-    my $class = $self->_component_name;
+    my $class = $self->catalyst_component_name;
     #this is still not correct for some reason.
     my $namespace = $self->action_namespace($c);
 
index 73d3f9c..d7a9a2c 100644 (file)
@@ -11,13 +11,13 @@ use Catalyst::Test 'TestApp';
     my $response = request('http://localhost/anon/test');
     ok($response->is_success);
     is($response->header('X-Component-Name-Action'),
-        'TestApp::Controller::Anon', 'Action can see correct _component_name');
+        'TestApp::Controller::Anon', 'Action can see correct catalyst_component_name');
     isnt($response->header('X-Component-Instance-Name-Action'),
-        'TestApp::Controller::Anon', 'ref($controller) ne _component_name');
+        'TestApp::Controller::Anon', 'ref($controller) ne catalyst_component_name');
     is($response->header('X-Component-Name-Controller'),
-        'TestApp::Controller::Anon', 'Controller can see correct _component_name');
+        'TestApp::Controller::Anon', 'Controller can see correct catalyst_component_name');
     is($response->header('X-Class-In-Action'),
-        'TestApp::Controller::Anon', '$action->class is _component_name');
+        'TestApp::Controller::Anon', '$action->class is catalyst_component_name');
     is($response->header('X-Anon-Trait-Applied'),
         '1', 'Anon controller class has trait applied correctly');
 }
index 77e2caa..1240b0e 100644 (file)
@@ -9,7 +9,7 @@ sub execute {
     my $self = shift;
     my ( $controller, $c, $test ) = @_;
     $c->res->header( 'X-TestAppActionTestMyAction', 'MyAction works' );
-    $c->res->header( 'X-Component-Name-Action', $controller->_component_name);
+    $c->res->header( 'X-Component-Name-Action', $controller->catalyst_component_name);
     $c->res->header( 'X-Component-Instance-Name-Action', ref($controller));
     $c->res->header( 'X-Class-In-Action', $self->class);
     $self->next::method(@_);
index 9832715..68b4fd6 100644 (file)
@@ -32,7 +32,7 @@ sub COMPONENT { # Don't do this yourself, use CatalystX::Component::Traits!
 
 sub test : Local ActionClass('+TestApp::Action::TestMyAction') {
     my ($self, $c) = @_;
-    $c->res->header('X-Component-Name-Controller', $self->_component_name);
+    $c->res->header('X-Component-Name-Controller', $self->catalyst_component_name);
     $c->res->body('It works');
 }