));
__PACKAGE__->meta->add_attribute('role_applications' => (
- reader => 'role_applications',
+ reader => '_get_role_applications',
default => sub { [] }
));
-
__PACKAGE__->meta->add_attribute(
Class::MOP::Attribute->new('immutable_trait' => (
accessor => "immutable_trait",
push @{$self->roles} => $role;
}
+sub role_applications {
+ my ($self) = @_;
+
+ return @{$self->_get_role_applications};
+}
+
sub add_role_application {
my ($self, $application) = @_;
(blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass'))
|| $self->throw_error("Role applications must be instances of Moose::Meta::Role::Application::ToClass", data => $application);
- push @{$self->role_applications} => $application;
+ push @{$self->_get_role_applications} => $application;
}
sub calculate_all_roles {
=item B<< $metaclass->role_applications >>
-Returns an array reference of L<Moose::Meta::Role::Application::ToClass>
+Returns a list of L<Moose::Meta::Role::Application::ToClass>
objects, which contain the arguments to role application.
=item B<< $metaclass->add_role_application($application) >>
sub foo { }
};
-my @basic = @{ Consumer::Basic->meta->role_applications };
-my @excludes = @{ Consumer::Excludes->meta->role_applications };
-my @aliases = @{ Consumer::Aliases->meta->role_applications };
-my @overrides = @{ Consumer::Overrides->meta->role_applications };
+my @basic = Consumer::Basic->meta->role_applications;
+my @excludes = Consumer::Excludes->meta->role_applications;
+my @aliases = Consumer::Aliases->meta->role_applications;
+my @overrides = Consumer::Overrides->meta->role_applications;
is(@basic, 1);
is(@excludes, 1);