Add test in Class:MOP for ->identifier() and immutable not playing nice. Fix by makin...
[gitmo/Class-MOP.git] / lib / Class / MOP / Immutable.pm
index 3cb1054..f4a84b0 100644 (file)
@@ -8,6 +8,7 @@ use Class::MOP::Method::Constructor;
 
 use Carp         'confess';
 use Scalar::Util 'blessed';
+use Sub::Name    'subname';
 
 our $VERSION   = '0.05';
 our $AUTHORITY = 'cpan:STEVAN';
@@ -233,6 +234,13 @@ sub create_methods_for_immutable_metaclass {
             $methods{$method_name} = sub { $_[0]->{'___' . $method_name} };
         }
     }
+    
+    my $around_methods = $self->options->{around};
+    foreach my $method_name (keys %{$around_methods}) {
+        my $method = $self->metaclass->meta->find_method_by_name($method_name);
+        $method = Class::MOP::Method::Wrapped->wrap($method);
+        $method->add_around_modifier(subname ':around' => $around_methods->{$method_name});
+    }
 
     $methods{get_mutable_metaclass_name} = sub { (shift)->{'___original_class'} };