From: nperez Date: Fri, 8 May 2009 18:10:24 +0000 (-0500) Subject: Populate insertion_order when attributes are added X-Git-Tag: 0.84~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c35dfd9f5e6a8b7ef0aac0eade00df1f62eeaa13;p=gitmo%2FClass-MOP.git Populate insertion_order when attributes are added --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 82ca2b2..1889d04 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -827,6 +827,10 @@ sub add_attribute { } else { $self->invalidate_meta_instances(); } + + # get our count of previously inserted attributes and + # increment by one so this attribute knows its order + $attribute->insertion_order((scalar keys %{$self->get_attribute_map}) + 1); # then onto installing the new accessors $self->get_attribute_map->{$attribute->name} = $attribute;