Skip to content

Commit

Permalink
Yeah, let's use namespace::clean then!
Browse files Browse the repository at this point in the history
  • Loading branch information
Getty committed Dec 18, 2012
1 parent 4e7edd0 commit 7aa92db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
1 change: 1 addition & 0 deletions dist.ini
Expand Up @@ -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
Expand Down
28 changes: 3 additions & 25 deletions lib/GID/Class.pm
Expand Up @@ -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 ();
Expand All @@ -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');

}

Expand Down

0 comments on commit 7aa92db

Please sign in to comment.