error_class and error_builder are readonly in immutable classes
[gitmo/Moose.git] / lib / Moose / Meta / Role / Composite.pm
index 5f2bd08..c68aff5 100644 (file)
@@ -4,12 +4,10 @@ use strict;
 use warnings;
 use metaclass;
 
-use Carp            'confess';
-use Scalar::Util    'blessed', 'reftype';
+use Carp         'confess';
+use Scalar::Util 'blessed';
 
-use Data::Dumper;
-
-our $VERSION   = '0.01';
+our $VERSION   = '0.50';
 our $AUTHORITY = 'cpan:STEVAN';
 
 use base 'Moose::Meta::Role';
@@ -54,11 +52,15 @@ sub alias_method {
     (defined $method_name && $method_name)
         || confess "You must define a method name";
 
-    my $body = (blessed($method) ? $method->body : $method);
-    ('CODE' eq (reftype($body) || ''))
-        || confess "Your code block must be a CODE reference";
+    # make sure to bless the 
+    # method if nessecary 
+    $method = $self->method_metaclass->wrap(
+        $method,
+        package_name => $self->name,
+        name         => $method_name
+    ) if !blessed($method);
 
-    $self->get_method_map->{$method_name} = $body;
+    $self->get_method_map->{$method_name} = $method;
 }
 
 1;