File Coverage

blib/lib/Mojo/Base/Role/PromiseClass.pm
Criterion Covered Total %
statement 10 10 100.0
branch 3 4 75.0
condition 3 3 100.0
subroutine 2 2 100.0
pod 1 1 100.0
total 19 20 95.0


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