[Catalyst-commits] r8807 - in Catalyst-Runtime/5.80/trunk: . lib/Catalyst

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Tue Dec 9 23:31:10 GMT 2008


Author: t0m
Date: 2008-12-09 23:31:09 +0000 (Tue, 09 Dec 2008)
New Revision: 8807

Modified:
   Catalyst-Runtime/5.80/trunk/Changes
   Catalyst-Runtime/5.80/trunk/lib/Catalyst/Controller.pm
Log:
Clean up around method modifier

Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes	2008-12-09 23:19:50 UTC (rev 8806)
+++ Catalyst-Runtime/5.80/trunk/Changes	2008-12-09 23:31:09 UTC (rev 8807)
@@ -1,5 +1,7 @@
 # This file documents the revision history for Perl extension Catalyst.
 
+        - Switch an around 'new' in Catalyst::Controller to a BUILDARGS
+          method as it's much neater and more obvious what is going on (t0m)
         - Add a clearer method on request and response _context 
           attributes, and use if from ::Engine rather than deleting
           the key from the instance hash (t0m)

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Controller.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Controller.pm	2008-12-09 23:19:50 UTC (rev 8806)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Controller.pm	2008-12-09 23:31:09 UTC (rev 8807)
@@ -32,10 +32,20 @@
      init_arg => undef,
     );
 
-# isa => 'ClassName|Catalyst' ?
-has _application => (is => 'rw');
-sub _app{ shift->_application(@_) } 
+# Future - isa => 'ClassName|Catalyst' performance?
+#           required => 1 breaks tests..
+has _application => (is => 'ro');
+sub _app { shift->_application(@_) } 
 
+override 'BUILDARGS' => sub {
+    my ($self, $app) = @_;
+    
+    my $args = super();
+    $args->{_application} = $app;
+ 
+    return $args;
+};
+
 sub BUILD {
     my ($self, $args) = @_;
     my $action  = delete $args->{action}  || {};
@@ -122,15 +132,6 @@
     return !@{ $c->error };
 }
 
-around new => sub {
-    my $orig = shift;
-    my $self = shift;
-    my $app = $_[0];
-    my $new = $self->$orig(@_);
-    $new->_application( $app );
-    return $new;
-};
-
 sub action_for {
     my ( $self, $name ) = @_;
     my $app = ($self->isa('Catalyst') ? $self : $self->_application);




More information about the Catalyst-commits mailing list