- when an attribute property is malformed (such as lazy without
a default), give the name of the attribute in the error
message (Sartak)
+ - added the &applied_traits and &has_applied_traits methods
+ to allow introspection of traits
+ - added tests for this
* Moose::Object
- localize $@ inside DEMOLISHALL to avoid it
Returns true if this meta-attribute has any documentation.
+=item B<applied_traits>
+
+This will return the ARRAY ref of all the traits applied to this
+attribute, or if no traits have been applied, it returns C<undef>.
+
+=item B<has_applied_traits>
+
+Returns true if this meta-attribute has any traits applied.
+
=back
=head1 BUGS
use strict;
use warnings;
-use Test::More tests => 9;
+use Test::More tests => 12;
use Test::Exception;
use Test::Moose;
my $bar_attr = $c->meta->get_attribute('bar');
does_ok($bar_attr, 'My::Attribute::Trait');
+ok($bar_attr->has_applied_traits, '... got the applied traits');
is_deeply($bar_attr->applied_traits, [qw/My::Attribute::Trait/], '... got the applied traits');
-ok(!$c->meta->get_attribute('gorch')->does('My::Attribute::Trait'), '... gorch doesnt do the trait');
+my $gorch_attr = $c->meta->get_attribute('gorch');
+ok(!$gorch_attr->does('My::Attribute::Trait'), '... gorch doesnt do the trait');
+ok(!$gorch_attr->has_applied_traits, '... no traits applied');
+is($gorch_attr->applied_traits, undef, '... no traits applied');