[Catalyst-commits] r9566 - Catalyst-Runtime/5.70/trunk/lib

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Mon Mar 23 23:29:02 GMT 2009


Author: t0m
Date: 2009-03-23 23:29:02 +0000 (Mon, 23 Mar 2009)
New Revision: 9566

Modified:
   Catalyst-Runtime/5.70/trunk/lib/Catalyst.pm
Log:
svn merge -r 9370:9371 http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Runtime/5.80/trunk
Lame hack to make the warnings about component resolution not hard code ->model in the warnings message (t0m)

Modified: Catalyst-Runtime/5.70/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.70/trunk/lib/Catalyst.pm	2009-03-23 18:00:29 UTC (rev 9565)
+++ Catalyst-Runtime/5.70/trunk/lib/Catalyst.pm	2009-03-23 23:29:02 UTC (rev 9566)
@@ -461,6 +461,7 @@
     my ( $c, $name, @prefixes ) = @_;
     my $appclass = ref $c || $c;
     my $filter   = "^${appclass}::(" . join( '|', @prefixes ) . ')::';
+    $filter = qr/$filter/; # Compile regex now rather than once per loop
 
     # map the original component name to the sub part that we will search against
     my %eligible = map { my $n = $_; $n =~ s{^$appclass\::[^:]+::}{}; $_ => $n; }
@@ -488,7 +489,9 @@
 
     # don't warn if we didn't find any results, it just might not exist
     if( @result ) {
-        my $msg = "Used regexp fallback for \$c->model('${name}'), which found '" .
+        # Disgusting hack to work out correct method name
+        my $warn_for = lc $prefixes[0];
+        my $msg = "Used regexp fallback for \$c->{$warn_for}('${name}'), which found '" .
            (join '", "', @result) . "'. Relying on regexp fallback behavior for " .
            "component resolution is unreliable and unsafe.";
         my $short = $result[0];
@@ -501,9 +504,9 @@
            $msg .= " You probably need to set '$short' instead of '${name}' in this " .
               "component's config";
         } else {
-           $msg .= " You probably meant \$c->model('$short') instead of \$c->model{'${name}'}, " .
+           $msg .= " You probably meant \$c->${warn_for}('$short') instead of \$c->${warn_for}({'${name}'}), " .
               "but if you really wanted to search, pass in a regexp as the argument " .
-              "like so: \$c->model(qr/${name}/)";
+              "like so: \$c->${warn_for}(qr/${name}/)";
         }
         $c->log->warn( "${msg}$shortmess" );
     }




More information about the Catalyst-commits mailing list