File Coverage

blib/lib/MooseX/Role/WithOverloading/Meta/Role/Application/ToRole.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package MooseX::Role::WithOverloading::Meta::Role::Application::ToRole;
2              
3             our $VERSION = '0.17';
4              
5 9     9   7578 use Moose::Role;
  9         32  
  9         62  
6 9     9   45280 use aliased 'MooseX::Role::WithOverloading::Meta::Role::Application::ToClass';
  9         19  
  9         79  
7 9     9   828 use aliased 'MooseX::Role::WithOverloading::Meta::Role::Application::ToInstance';
  9         18  
  9         50  
8 9     9   874 use namespace::autoclean;
  9         18  
  9         63  
9              
10             with 'MooseX::Role::WithOverloading::Meta::Role::Application';
11              
12             around apply => sub {
13             my ($next, $self, $role1, $role2) = @_;
14             my $new_role2 = Moose::Util::MetaRole::apply_metaroles(
15             for => $role2,
16             role_metaroles => {
17             application_to_class => [ToClass],
18             application_to_role => [__PACKAGE__],
19             application_to_instance => [ToInstance],
20             },
21             );
22             # Horrible hack as we have just got a new metaclass with no attributes
23             foreach my $name ( $role2->get_attribute_list ) {
24             $new_role2->add_attribute($role2->get_attribute($name));
25             }
26              
27             return $self->$next($role1, $new_role2);
28             };
29              
30             1;