Make role_applications return a list not an arrayref
Shawn M Moore [Sun, 3 May 2009 19:04:59 +0000 (15:04 -0400)]
lib/Moose/Meta/Class.pm
t/030_roles/039_application_toclass.t

index de9da90..09a0d33 100644 (file)
@@ -30,11 +30,10 @@ __PACKAGE__->meta->add_attribute('roles' => (
 ));
 
 __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",
@@ -141,11 +140,17 @@ sub add_role {
     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 {
@@ -709,7 +714,7 @@ list of roles. This I<does not> actually apply the role to the class.
 
 =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) >>
index 930d9a3..67c7d4e 100644 (file)
@@ -33,10 +33,10 @@ do {
     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);