this way, roles don't just automatically absorb the class's attribute
metaclass (at the moment, using MooseX::FollowPBP in a class can just
break a role that doesn't use it). also, allows this to be customized by
metarole, since you almost always want to be modifying the eventual
class attribute, not the role attribute
default => 'Moose::Meta::Role::Application::ToInstance',
);
+$META->add_attribute(
+ 'applied_attribute_metaclass',
+ reader => 'applied_attribute_metaclass',
+ default => 'Moose::Meta::Attribute',
+);
+
# More or less copied from Moose::Meta::Class
sub initialize {
my $class = shift;
application_to_class_class
application_to_role_class
application_to_instance_class
+ applied_attribute_metaclass
);
}
sub apply_attributes {
my ($self, $role, $class) = @_;
- my $attr_metaclass = $class->attribute_metaclass;
+ my $attr_metaclass = $role->applied_attribute_metaclass;
foreach my $attribute_name ($role->get_attribute_list) {
# it if it has one already