clean up implements implementation by providing an add_method_to_target method in...
[catagits/Reaction.git] / lib / Reaction / Role.pm
index 13815db..f5e89b5 100644 (file)
@@ -5,27 +5,7 @@ use Reaction::ClassExporter;
 use Reaction::Class;
 use Moose::Meta::Class;
 
-use Sub::Name 'subname';
-use Scalar::Util qw/blessed reftype/;
-
 #TODO: review for Reaction::Object switch / Reaction::Meta::Class
-#lifted from class MOP as a temp fix (groditi)
-*Moose::Meta::Role::add_method
-  = subname 'Moose::Meta::Role::add_method' => sub {
-    my ($self, $method_name, $code) = @_;
-    (defined $method_name && $method_name)
-      || confess "You must define a method name";
-
-    confess "Your code block must be a CODE reference"
-      unless 'CODE' eq reftype($code);
-
-    my $method = $self->method_metaclass->wrap($code);
-    $self->get_method_map->{$method_name} = $method;
-
-    my $full_name = ($self->name . '::' . $method_name);
-    $self->add_package_symbol("&${method_name}" => subname $full_name => $code);
-  };
-
 
 class Role which {
 
@@ -41,6 +21,11 @@ class Role which {
 
   override default_base => sub { () };
 
+  override add_method_to_target => sub {
+    my ($self, $target, $method) = @_;
+    $target->meta->alias_method(@$method);
+  };
+
   implements do_role_sub => as {
     my ($self, $package, $role, $which, $setup) = @_;
     confess "Invalid role declaration, should be: role Role which { ... }"