File Coverage

blib/lib/MouseX/Foreign/Meta/Role/Method/Constructor.pm
Criterion Covered Total %
statement 12 12 100.0
branch 3 4 75.0
condition n/a
subroutine 4 4 100.0
pod n/a
total 19 20 95.0


line stmt bran cond sub pod time code
1             package MouseX::Foreign::Meta::Role::Method::Constructor;
2 30     42   38463 use Mouse::Role;
  30         73  
  30         303  
3              
4             around _generate_constructor => sub {
5             my($next, undef, $meta, $option) = @_;
6              
7             # The foreign superlcass must have the new method
8             my $foreign_buildargs = $meta->name->can('FOREIGNBUILDARGS');
9             my $foreign_superclass = $meta->foreign_superclass;
10             my $super_new = $foreign_superclass->can('new');
11             my $needs_buildall = !$foreign_superclass->can('BUILDALL');
12              
13             return sub {
14 73     73   64203 my $class = shift;
        48      
15 73         3598 my $args = $class->BUILDARGS(@_);
16 73 100       718 my $object = $foreign_buildargs
17             ? $class->$super_new($class->$foreign_buildargs(@_))
18             : $class->$super_new( @_ );
19 73         23448 $object->meta->_initialize_object($object, $args);
20 73 50       9996 $object->BUILDALL($args) if $needs_buildall;
21              
22 73         363 return $object;
23             };
24             };
25              
26 30     30   18701 no Mouse::Role;
  30         119  
  30         199  
27             1;
28             __END__