version 1.1, 2010/01/23 07:04:43 |
version 1.3, 2010/01/26 05:05:34 |
|
|
package Text::Todo::REST::API::Response; |
package Text::Todo::REST::API::Response; |
|
|
# $AFresh1$ |
# $AFresh1: Response.pm,v 1.2 2010/01/24 04:17:39 andrew Exp $ |
|
|
use warnings; |
use warnings; |
use strict; |
use strict; |
|
|
return $self; |
return $self; |
} |
} |
|
|
#sub content_type { |
sub content_type { |
#my ($self) = shift; |
my ($self) = shift; |
#my $ident = ident($self); |
return $self->_handle_representation('content_type'); |
#return defined $content_type_of{$ident} |
} |
#} |
|
|
|
sub _handle_representation { |
sub _handle_representation { |
my ( $self, $method, $options ) = @_; |
my ( $self, $method, $options ) = @_; |
|
|
$method = join q{_}, $method, $self->_type; |
if ($method ne 'content_type') { |
|
$method = join q{_}, $method, $self->type; |
|
} |
|
|
my $format = $self->_format; |
my $format = $self->format; |
if ( $options->{format} ) { |
if ( $options->{format} ) { |
$format = $options->{format}; |
$format = $options->{format}; |
} |
} |
|
|
if ( $class->can_render($format) |
if ( $class->can_render($format) |
&& $class->can($method) ) |
&& $class->can($method) ) |
{ |
{ |
return $class->$method( $format, $self->_data ); |
return $class->$method( $format, $self->data ); |
} |
} |
} |
} |
|
|
|
|
croak(@message); |
croak(@message); |
} |
} |
|
|
sub _format { my ($self) = @_; return $format_of{ ident $self}; } |
sub format { my ($self) = @_; return $format_of{ ident $self}; } |
sub _type { my ($self) = @_; return $type_of{ ident $self}; } |
sub type { my ($self) = @_; return $type_of{ ident $self}; } |
sub _data { my ($self) = @_; return $data_of{ ident $self}; } |
sub data { my ($self) = @_; return $data_of{ ident $self}; } |
|
|
sub DESTROY { |
sub DESTROY { |
my ($self) = @_; |
my ($self) = @_; |