X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAction%2FSerializeBase.pm;h=3bb34279cf589e8d0b3981d9d1ea80ec21b421c8;hb=fix-accepted-content-types;hp=7892ea4f178978c101299ac119bfc950eb74f24e;hpb=f465980c3c25b475d878716b7341d0a4f5c8f823;p=catagits%2FCatalyst-Action-REST.git diff --git a/lib/Catalyst/Action/SerializeBase.pm b/lib/Catalyst/Action/SerializeBase.pm index 7892ea4..3bb3427 100644 --- a/lib/Catalyst/Action/SerializeBase.pm +++ b/lib/Catalyst/Action/SerializeBase.pm @@ -8,17 +8,16 @@ use Module::Pluggable::Object; use Catalyst::Request::REST; use Catalyst::Utils (); -our $VERSION = '0.81'; +our $VERSION = '0.90'; $VERSION = eval $VERSION; -sub new { - my $class = shift; - my $config = shift; - Catalyst::Request::REST->_insert_self_into( $config->{class} ); - return $class->SUPER::new($config, @_); -} +after BUILDARGS => sub { + my $class = shift; + my $config = shift; + Catalyst::Request::REST->_insert_self_into( $config->{class} ); +}; -__PACKAGE__->mk_accessors(qw(_serialize_plugins _loaded_plugins)); +has [qw(_serialize_plugins _loaded_plugins)] => ( is => 'rw' ); sub _load_content_plugins { my $self = shift; @@ -70,7 +69,12 @@ sub _load_content_plugins { push @accepted_types, @$stashed; } # then content types requested by caller - push @accepted_types, @{ $c->request->accepted_content_types }; + push @accepted_types, + $search_path =~ m{Deserialize} + ? @{ $c->request->accepted_content_types } + : @{ $c->request->accepted_response_content_types } + ; + # then the default push @accepted_types, $config->{'default'} if $config->{'default'}; # pick the best match that we have a serializer mapping for @@ -156,13 +160,13 @@ sub _serialize_bad_request { return undef; } +__PACKAGE__->meta->make_immutable; + 1; =head1 NAME -B - -Base class for Catalyst::Action::Serialize and Catlayst::Action::Deserialize. +Catalyst::Action::SerializeBase - Base class for Catalyst::Action::Serialize and Catlayst::Action::Deserialize. =head1 DESCRIPTION