Update the Serialize and Deserialize classes to use Moose
Tomas Doran [Mon, 18 Jan 2010 21:03:02 +0000 (21:03 +0000)]
Changes
lib/Catalyst/Action/Deserialize.pm
lib/Catalyst/Action/Serialize.pm
lib/Catalyst/Action/SerializeBase.pm

diff --git a/Changes b/Changes
index 3ed2a7d..d014df3 100644 (file)
--- a/Changes
+++ b/Changes
@@ -17,6 +17,9 @@
   install Catalyst::Request::REST::ForBrowsers, they get the version in this
   distro. (Dave Rolsky)
 
+  Change Catalyst::Action::Serialize, Catalyst::Action::Deserialize and
+  Catalyst::Action::SerializeBase to be more Moose like.
+
   Fix doc nits (RT#53780)
 
 Thu 14 Jan 20:56:00 GMT 2010 - Release 0.81
index 5170f25..b779f7c 100644 (file)
@@ -10,7 +10,7 @@ use MRO::Compat;
 our $VERSION = '0.81';
 $VERSION = eval $VERSION;
 
-__PACKAGE__->mk_accessors(qw(plugins));
+has plugins => ( is => 'rw' );
 
 sub execute {
     my $self = shift;
@@ -41,6 +41,8 @@ sub execute {
     return 1;
 }
 
+__PACKAGE__->meta->make_immutable;
+
 =head1 NAME
 
 Catalyst::Action::Deserialize - Deserialize Data in a Request
@@ -101,5 +103,3 @@ See L<Catalyst::Action::REST> for authors.
 You may distribute this code under the same terms as Perl itself.
 
 =cut
-
-1;
index 0ce4558..cc1f838 100644 (file)
@@ -53,7 +53,7 @@ sub execute {
     return 1;
 }
 
-1;
+__PACKAGE__->meta->make_immutable;
 
 =head1 NAME
 
index f5a0df3..87950aa 100644 (file)
@@ -11,14 +11,13 @@ use Catalyst::Utils ();
 our $VERSION = '0.81';
 $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;
@@ -156,7 +155,7 @@ sub _serialize_bad_request {
     return undef;
 }
 
-1;
+__PACKAGE__->meta->make_immutable;
 
 =head1 NAME