Enable hooking parameters into req/res construction. Useful if you are dynamically...
Tomas Doran [Mon, 8 Oct 2012 19:04:40 +0000 (20:04 +0100)]
Changes
lib/Catalyst.pm

diff --git a/Changes b/Changes
index 9f23ad3..a7b3758 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 # This file documents the revision history for Perl extension Catalyst.
 
+  - Refactor request and response class construction to add methods
+    that roles can hook to feed extra parameters into the constructor
+    of request or response classes.
+
 5.90016 - 2012-08-16 15:35:00
   - prepare_parameters is no longer an attribute builder.  It is now a method
     that calls the correct underlying functionality (Bill Moseley++)
index ea5507d..b959d7c 100644 (file)
@@ -52,20 +52,30 @@ has request => (
     is => 'rw',
     default => sub {
         my $self = shift;
-        my %p = ( _log => $self->log );
-        $p{_uploadtmp} = $self->_uploadtmp if $self->_has_uploadtmp;
-        $self->request_class->new(\%p);
+        $self->request_class->new($self->_build_request_class_construction_parameters);
     },
     lazy => 1,
 );
+sub _build_request_class_construction_parameters {
+    my $self = shift;
+    my %p = ( _log => $self->log );
+    $p{_uploadtmp} = $self->_uploadtmp if $self->_has_uploadtmp;
+    \%p;
+}
+
 has response => (
     is => 'rw',
     default => sub {
         my $self = shift;
-        $self->response_class->new({ _log => $self->log });
+        $self->response_class->new($self->_build_response_class_construction_parameters);
     },
     lazy => 1,
 );
+sub _build_response_class_construction_parameters {
+    my $self = shift;
+    { _log => $self->log };
+}
+
 has namespace => (is => 'rw');
 
 sub depth { scalar @{ shift->stack || [] }; }