enabling immutable finishing porting Log and stats
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Response.pm
index 877f8c9..3b57cab 100644 (file)
@@ -1,16 +1,24 @@
 package Catalyst::Response;
 
-use strict;
-use base 'Class::Accessor::Fast';
+use Moose;
 
-__PACKAGE__->mk_accessors(qw/cookies body headers location status/);
+has cookies   => (is => 'rw');
+has body      => (is => 'rw');
+has location  => (is => 'rw');
+has status    => (is => 'rw');
+has headers   => (
+  is      => 'rw',
+  handles => [qw(content_encoding content_length content_type header)],
+);
 
-*output = \&body;
+has _context => (
+  is => 'rw',
+  weak_ref => 1,
+);
 
-sub content_encoding { shift->headers->content_encoding(@_) }
-sub content_length   { shift->headers->content_length(@_) }
-sub content_type     { shift->headers->content_type(@_) }
-sub header           { shift->headers->header(@_) }
+sub output { shift->body(@_) }
+
+no Moose;
 
 =head1 NAME
 
@@ -76,7 +84,7 @@ The keys of the hash reference on the right correspond to the L<CGI::Cookie>
 parameters of the same name, except they are used without a leading dash.
 Possible parameters are:
 
-=over 
+=over
 
 =item value
 
@@ -127,19 +135,27 @@ sub redirect {
     return $self->location;
 }
 
+=head2 $res->location
+
+Sets or returns the HTTP 'Location'.
+
 =head2 $res->status
 
 Sets or returns the HTTP status.
 
     $c->response->status(404);
-    
+
 =head2 $res->write( $data )
 
 Writes $data to the output stream.
 
 =cut
 
-sub write { shift->{_context}->write(@_); }
+sub write { shift->_context->write(@_); }
+
+=head2 meta
+
+Provided by Moose
 
 =head1 AUTHORS
 
@@ -149,9 +165,11 @@ Marcus Ramberg, C<mramberg@cpan.org>
 
 =head1 COPYRIGHT
 
-This program is free software, you can redistribute it and/or modify 
+This program is free software, you can redistribute it and/or modify
 it under the same terms as Perl itself.
 
 =cut
 
+__PACKAGE__->meta->make_immutable;
+
 1;