convert the rest of the simple readers in cmop to xs
[gitmo/Class-MOP.git] / lib / Class / MOP / Mixin / HasAttributes.pm
index 58736ce..eed360b 100644 (file)
@@ -3,7 +3,7 @@ package Class::MOP::Mixin::HasAttributes;
 use strict;
 use warnings;
 
-our $VERSION   = '1.02';
+our $VERSION   = '1.11';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -12,9 +12,6 @@ use Scalar::Util 'blessed';
 
 use base 'Class::MOP::Mixin';
 
-sub _attribute_map      { $_[0]->{'attributes'} }
-sub attribute_metaclass { $_[0]->{'attribute_metaclass'} }
-
 sub add_attribute {
     my $self = shift;
 
@@ -85,6 +82,18 @@ sub get_attribute_list {
     keys %{ $self->_attribute_map };
 }
 
+sub _restore_metaattributes_from {
+    my $self = shift;
+    my ($old_meta) = @_;
+
+    for my $attr (sort { $a->insertion_order <=> $b->insertion_order }
+                       map { $old_meta->get_attribute($_) }
+                           $old_meta->get_attribute_list) {
+        $attr->_make_compatible_with($self->attribute_metaclass);
+        $self->add_attribute($attr);
+    }
+}
+
 1;
 
 __END__