From 7aa92db6cae13a2a39e64aed6dfe72ddd2e60052 Mon Sep 17 00:00:00 2001 From: Torsten Raudssus Date: Tue, 18 Dec 2012 18:20:54 +0100 Subject: [PATCH] Yeah, let's use namespace::clean then! --- dist.ini | 1 + lib/GID/Class.pm | 28 +++------------------------- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/dist.ini b/dist.ini index 5698a9a..3975b0c 100644 --- a/dist.ini +++ b/dist.ini @@ -30,6 +30,7 @@ URL::Encode = 0.01 URI = 1.60 LWP::Simple = 6.00 Class::Method::Modifiers = 1.12 +namespace::clean = 0.24 [Prereqs / TestRequires] Test::More = 0.98 diff --git a/lib/GID/Class.pm b/lib/GID/Class.pm index 5806c60..c3610c7 100644 --- a/lib/GID/Class.pm +++ b/lib/GID/Class.pm @@ -17,6 +17,7 @@ package GID::Class; use strictures 1; use Import::Into; use Scalar::Util qw( blessed ); +use namespace::clean (); use GID (); use MooX (); @@ -38,32 +39,9 @@ sub import { Types::MooseLike )); - $target->can('extends')->('GID::Object'); + namespace::clean->import::into($target); - $target->class_stash->around_method('has',sub { - my $has = shift; - my $attribute_arg = shift; - my @attribute_args = @_; - my @attributes = ref $attribute_arg eq 'ARRAY' ? @{$attribute_arg} : ($attribute_arg); - for my $attribute (@attributes) { - if (grep { $attribute eq $_ } @gid_methods) { - my $gid_method = $target->class_stash->get_method($attribute); - $target->class_stash->remove_method($attribute); - $has->($attribute,@attribute_args); - $target->class_stash->around_method($attribute,sub { - my $attribute_method = shift; - my @args = @_; - if (blessed $args[0]) { - return $attribute_method->(@args); - } else { - return $gid_method->(@args); - } - }); - } else { - $has->($attribute,@attribute_args); - } - } - }); + $target->can('extends')->('GID::Object'); }