The Go and visit tests don't like this as you get told to go away in a different...
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Component.pm
index ee1f99a..a55e7d2 100644 (file)
@@ -10,9 +10,11 @@ use mro 'c3';
 use Scalar::Util 'blessed';
 use namespace::clean -except => 'meta';
 
-with 'MooseX::Emulate::Class::Accessor::Fast';
-with 'Catalyst::ClassData';
-
+with qw/
+    MooseX::Emulate::Class::Accessor::Fast
+    Catalyst::Config
+    Catalyst::ClassData
+/;
 
 =head1 NAME
 
@@ -60,13 +62,16 @@ 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
-around _component_name => sub {
+# 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 catalyst_component_name => sub {
     my ($orig, $self) = (shift, shift);
-    blessed($self) ? $self->$orig(@_) : $self;
+    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;
 };
 
 sub BUILDARGS {
@@ -110,6 +115,8 @@ sub COMPONENT {
 
 sub config {
     my $self = shift;
+    # Uncomment once sane to do so
+    #Carp::cluck("config method called on instance") if ref $self;
     my $config = $self->_config || {};
     if (@_) {
         my $newconfig = { %{@_ > 1 ? {@_} : $_[0]} };