File Coverage

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


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