From 2b83702afe0f845311fedae8d71b6b51dd5f7f2c Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 3 Oct 2011 22:58:51 -0500 Subject: oh yeah, this exists --- lib/OXx/Encoding.pm | 19 +++++++------------ lib/OXx/Encoding/Role/Request.pm | 19 +++++++------------ 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/lib/OXx/Encoding.pm b/lib/OXx/Encoding.pm index 729c5a3..8e6103c 100644 --- a/lib/OXx/Encoding.pm +++ b/lib/OXx/Encoding.pm @@ -2,6 +2,7 @@ package OXx::Encoding; use MooseX::Role::Parameterized; use namespace::autoclean; +use Moose::Util 'with_traits'; use OXx::Encoding::Types; parameter encoding => ( @@ -22,18 +23,12 @@ role { my $orig = shift; my $self = shift; - my $super = $self->$orig(@_); - - return Moose::Meta::Class->create_anon_class( - superclasses => [$super], - roles => [ - 'OXx::Encoding::Role::Request' => { - encoding => $p->encoding, - html_encoding => $p->html_encoding, - }, - ], - cache => 1, - )->name; + return with_traits($self->$orig(@_), + 'OXx::Encoding::Role::Request' => { + encoding => $p->encoding, + html_encoding => $p->html_encoding, + }, + ); }; } diff --git a/lib/OXx/Encoding/Role/Request.pm b/lib/OXx/Encoding/Role/Request.pm index a41c74b..4f50046 100644 --- a/lib/OXx/Encoding/Role/Request.pm +++ b/lib/OXx/Encoding/Role/Request.pm @@ -3,6 +3,7 @@ use MooseX::Role::Parameterized; use namespace::autoclean; use Encode (); +use Moose::Util 'with_traits'; use OXx::Encoding::Types; parameter encoding => ( @@ -37,18 +38,12 @@ role { my $orig = shift; my $self = shift; - my $super = $self->$orig(@_); - - return Moose::Meta::Class->create_anon_class( - superclasses => [$super], - roles => [ - 'OXx::Encoding::Role::Response' => { - encoding => $p->encoding, - html_encoding => $p->html_encoding, - }, - ], - cache => 1, - )->name; + return with_traits($self->$orig(@_), + 'OXx::Encoding::Role::Response' => { + encoding => $p->encoding, + html_encoding => $p->html_encoding, + }, + ); }; } -- cgit v1.2.3-54-g00ecf