From: Tomas Doran Date: Thu, 16 Jul 2009 21:05:25 +0000 (+0000) Subject: Special move for CX::Component::Traits. No tests, please don't look. X-Git-Tag: 5.80008~60 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=db575fe81b23c74267b50495a881796f6cee7795 Special move for CX::Component::Traits. No tests, please don't look. --- diff --git a/Changes b/Changes index 70a4777..aab4a17 100644 --- a/Changes +++ b/Changes @@ -10,6 +10,8 @@ - Deleted the Restarter engine and its Watcher code. Use the new Catalyst::Restarter in a recent Catalyst::Devel instead. - New unit test for Catalyst::Action 'unit_core_action.t' (groditi) + - Components being anonymous classes at runtime is now correctly dealt with + by class2appclass to support CatalystX::Component::Traits New features: - private_path method for Catalyst::Action + docs + tests (groditi) diff --git a/lib/Catalyst/Utils.pm b/lib/Catalyst/Utils.pm index 05248fc..22675a9 100644 --- a/lib/Catalyst/Utils.pm +++ b/lib/Catalyst/Utils.pm @@ -8,8 +8,8 @@ use Path::Class; use URI; use Carp qw/croak/; use Cwd; - use String::RewritePrefix; +use Moose::Util qw/find_meta/; use namespace::clean; @@ -49,6 +49,19 @@ sub appprefix { sub class2appclass { my $class = shift || ''; + + # Special move to deal with components which are anon classes. + # Specifically, CX::Component::Traits c072fb2 + my $meta = find_meta($class); + if ($meta) { + while ($meta->is_anon_class) { + my @superclasses = $meta->superclasses; + return if scalar(@superclasses) > 1; # Fail silently, MI, can't deal.. + $class = $superclasses[0]; + $meta = find_meta($class); + } + } + my $appname = ''; if ( $class =~ /^(.+?)::([MVC]|Model|View|Controller)::.+$/ ) { $appname = $1;