File Coverage

blib/lib/Mojo/Base/Role/PromiseClass.pm
Criterion Covered Total %
statement 10 10 100.0
branch 4 4 100.0
condition n/a
subroutine 2 2 100.0
pod 1 1 100.0
total 17 17 100.0


line stmt bran cond sub pod time code
1             package Mojo::Base::Role::PromiseClass 0.009;
2              
3             # ABSTRACT: Add promise_class attribute to Mojo class
4              
5 1     1   760 use Mojo::Base -role;
  1         3  
  1         9  
6              
7             has promise_class => sub {'Mojo::Promise'};
8              
9             sub promise_roles {
10 7     7 1 31168 my $self = shift;
11 7         26 my $pclass = $self->promise_class;
12             my @roles =
13 6         24 grep { !Role::Tiny::does_role($pclass, $_) }
14 7 100       34 map { /^\+(.+)$/ ? "Mojo::Promise::Role::$1" : $_ }
  6         57  
15             @_;
16 7 100       155 $self->promise_class($pclass->with_roles(@roles)) if @roles;
17 7         1076 return $self;
18             }
19              
20             1;
21              
22             __END__