[Catalyst-commits] r11013 - in
Catalyst-Runtime/5.80/branches/pass_component_names/lib: . Catalyst
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Fri Jul 31 02:01:32 GMT 2009
Author: t0m
Date: 2009-07-31 02:01:32 +0000 (Fri, 31 Jul 2009)
New Revision: 11013
Modified:
Catalyst-Runtime/5.80/branches/pass_component_names/lib/Catalyst.pm
Catalyst-Runtime/5.80/branches/pass_component_names/lib/Catalyst/Component.pm
Catalyst-Runtime/5.80/branches/pass_component_names/lib/Catalyst/Controller.pm
Log:
Clean up branch. I'm happy with this (bar the eww, as commented) and intend to merge pre 0008, please review
Modified: Catalyst-Runtime/5.80/branches/pass_component_names/lib/Catalyst/Component.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/pass_component_names/lib/Catalyst/Component.pm 2009-07-31 01:46:00 UTC (rev 11012)
+++ Catalyst-Runtime/5.80/branches/pass_component_names/lib/Catalyst/Component.pm 2009-07-31 02:01:32 UTC (rev 11013)
@@ -60,7 +60,14 @@
__PACKAGE__->mk_classdata('_plugins');
__PACKAGE__->mk_classdata('_config');
-has _component_name => ( is => 'ro' );
+has _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 {
+ my ($orig, $self) = (shift, shift);
+ blessed($self) ? $self->$orig(@_) : $self;
+};
sub BUILDARGS {
my $class = shift;
@@ -172,15 +179,6 @@
return $class->new($app, $args);
}
-=head2 _component_name
-
-The name of the component within an application. This is used to
-pass the component's name to actions generated (becoming
-C<< $action->class >>). This is needed so that the L</COMPONENT> method can
-return an instance of a different class (e.g. a L<Class::MOP> anonymous class),
-(as finding the component name by C<< ref($self) >> will not work correctly in
-such cases).
-
=head2 $c->config
=head2 $c->config($hashref)
Modified: Catalyst-Runtime/5.80/branches/pass_component_names/lib/Catalyst/Controller.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/pass_component_names/lib/Catalyst/Controller.pm 2009-07-31 01:46:00 UTC (rev 11012)
+++ Catalyst-Runtime/5.80/branches/pass_component_names/lib/Catalyst/Controller.pm 2009-07-31 02:01:32 UTC (rev 11013)
@@ -156,7 +156,7 @@
}
}
- my $namespace = Catalyst::Utils::class2prefix(ref($self) ? $self->_component_name : $self, $case_s) || '';
+ my $namespace = Catalyst::Utils::class2prefix($self->_component_name, $case_s) || '';
$self->$orig($namespace) if ref($self);
return $namespace;
};
@@ -207,10 +207,15 @@
sub register_action_methods {
my ( $self, $c, @methods ) = @_;
- my $class = blessed($self) ? $self->_component_name : $self;
+ my $class = $self->_component_name;
#this is still not correct for some reason.
my $namespace = $self->action_namespace($c);
+ # Uncomment as soon as you fix the tests :)
+ #if (!blessed($self) && $self eq $c && scalar(@methods)) {
+ # $c->log->warn("Action methods found defined in your application class, $self. This is deprecated, please move them into a Root controller.");
+ #}
+
foreach my $method (@methods) {
my $name = $method->name;
my $attributes = $method->attributes;
Modified: Catalyst-Runtime/5.80/branches/pass_component_names/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/pass_component_names/lib/Catalyst.pm 2009-07-31 01:46:00 UTC (rev 11012)
+++ Catalyst-Runtime/5.80/branches/pass_component_names/lib/Catalyst.pm 2009-07-31 02:01:32 UTC (rev 11013)
@@ -2216,10 +2216,11 @@
my $suffix = Catalyst::Utils::class2classsuffix( $component );
my $config = $class->config->{ $suffix } || {};
- $config->{_component_name} = $component; # Put this in args here, rather
- # than in COMPONENT as there
- # are lots of custom COMPONENT
- # methods..
+ # Stash _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;
+
my $instance = eval { $component->COMPONENT( $class, $config ); };
if ( my $error = $@ ) {
More information about the Catalyst-commits
mailing list