From: Stevan Little Date: Fri, 28 Apr 2006 20:42:03 +0000 (+0000) Subject: slotnames X-Git-Tag: 0_29_02~34 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c57c8b10dc66355d65b7ef2aad88edd20d8adc21;p=gitmo%2FClass-MOP.git slotnames --- diff --git a/lib/Class/MOP/Attribute.pm b/lib/Class/MOP/Attribute.pm index 3190a4b..bb41bd7 100644 --- a/lib/Class/MOP/Attribute.pm +++ b/lib/Class/MOP/Attribute.pm @@ -112,6 +112,10 @@ sub default { $self->{default}; } +# slots + +sub slots { (shift)->name } + # class association sub attach_to_class { @@ -432,6 +436,11 @@ As noted in the documentation for C above, if the I value is a CODE reference, this accessor will pass a single additional argument C<$instance> into it and return the value. +=item B + +Returns a list of slots required by the attribute. This is usually +just one, which is the name of the attribute. + =back =head2 Informational predicates diff --git a/lib/Class/MOP/Instance.pm b/lib/Class/MOP/Instance.pm index b8e2450..d7bb7fb 100644 --- a/lib/Class/MOP/Instance.pm +++ b/lib/Class/MOP/Instance.pm @@ -16,7 +16,7 @@ sub meta { sub new { my ($class, $meta, @attrs) = @_; - my @slots = map { $_->name } @attrs; + my @slots = map { $_->slots } @attrs; bless { # NOTE: # I am not sure that it makes diff --git a/t/014_attribute_introspection.t b/t/014_attribute_introspection.t index 390fcc1..bb4af65 100644 --- a/t/014_attribute_introspection.t +++ b/t/014_attribute_introspection.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 40; +use Test::More tests => 41; use Test::Exception; BEGIN { @@ -33,6 +33,8 @@ BEGIN { has_init_arg init_arg has_default default + slots + associated_class attach_to_class detach_from_class