Fix the return value of Catalyst::Request's body method + tests.
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Request.pm
index 48253b9..f228099 100644 (file)
@@ -68,12 +68,6 @@ has uploads => (
   default => sub { {} },
 );
 
-# modifier was a noop (groditi)
-# before uploads => sub {
-#   my ($self) = @_;
-#   #$self->_context->prepare_body;
-# };
-
 has parameters => (
   is => 'rw',
   required => 1,
@@ -83,7 +77,6 @@ has parameters => (
 
 before parameters => sub {
   my ($self, $params) = @_;
-  #$self->_context->prepare_body();
   if ( $params && !ref $params ) {
     $self->_context->log->warn(
         "Attempt to retrieve '$params' with req->params(), " .
@@ -103,14 +96,17 @@ has base => (
   },
 );
 
-has body => (
-  is => 'rw'
+has _body => (
+  is => 'rw',
 );
-
-before body => sub {
-  my ($self) = @_;
+# Eugh, ugly. Should just be able to rename accessor methods to 'body'
+#             and provide a custom reader.. 
+sub body {
+  my $self = shift;
   $self->_context->prepare_body();
-};
+  $self->_body(@_) if scalar @_;
+  return blessed $self->_body ? $self->_body->body : $self->_body;
+}
 
 has hostname => (
   is        => 'rw',