X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FComponent.pm;h=b0bb7b5a58021c9fd82ecaf7d7851306d5f1e527;hb=fa7a60aac97d8a9501a2cdca54f519752c12731a;hp=0fbca47f77be75e5ac919289b0b6efce3dd8a19a;hpb=1b79e1994c40fc525b4a84c900a5c95ffd4a2f8a;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Component.pm b/lib/Catalyst/Component.pm index 0fbca47..b0bb7b5 100644 --- a/lib/Catalyst/Component.pm +++ b/lib/Catalyst/Component.pm @@ -60,7 +60,17 @@ component loader with config() support and a process() method placeholder. __PACKAGE__->mk_classdata('_plugins'); __PACKAGE__->mk_classdata('_config'); -has _component_name => ( is => 'ro' ); +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 catalyst_component_name => sub { + my ($orig, $self) = (shift, shift); + 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 { my $class = shift; @@ -74,7 +84,7 @@ sub BUILDARGS { } elsif (Class::MOP::is_class_loaded($_[0]) && $_[0]->isa('Catalyst') && ref($_[1]) eq 'HASH') { $args = $_[1]; - } elsif ($_[0] == $_[1]) { + } elsif ($_[0] eq $_[1]) { $args = $_[1]; } else { $args = +{ @_ }; @@ -103,6 +113,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]} };