From: Dave Rolsky Date: Sun, 5 Apr 2009 17:00:51 +0000 (-0500) Subject: Make attributes private. Even though it can be inlined at no cost in X-Git-Tag: 0.80_01~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=780f14c23e5ae0579d96c830bc668f94c3d248b1;p=gitmo%2FClass-MOP.git Make attributes private. Even though it can be inlined at no cost in CMOP, it's useful as a caching method for Moose. --- diff --git a/lib/Class/MOP/Method/Constructor.pm b/lib/Class/MOP/Method/Constructor.pm index 4358de9..65a3507 100644 --- a/lib/Class/MOP/Method/Constructor.pm +++ b/lib/Class/MOP/Method/Constructor.pm @@ -74,8 +74,12 @@ sub _meta_instance { sub attributes { warn 'The attributes method is deprecated.' - . " Use ->associated_metaclass->get_all_attributes instead.\n"; + . " Use _attributes instead.\n"; + return shift->_attributes; +} + +sub _attributes { my $self = shift; $self->{'attributes'} ||= [ $self->associated_metaclass->get_all_attributes ] } @@ -129,7 +133,7 @@ sub _generate_constructor_method_inline { $source .= "\n" . 'my $instance = ' . $self->_meta_instance->inline_create_instance('$class'); $source .= ";\n" . (join ";\n" => map { $self->_generate_slot_initializer($_, $close_over) - } $self->associated_metaclass->get_all_attributes); + } @{ $self->_attributes }); $source .= ";\n" . 'return $instance'; $source .= ";\n" . '}'; warn $source if $self->options->{debug};