File Coverage

blib/lib/Search/Elasticsearch/Role/Client/Async/Simple/Direct.pm
Criterion Covered Total %
statement 20 22 90.9
branch 6 6 100.0
condition n/a
subroutine 4 5 80.0
pod n/a
total 30 33 90.9


line stmt bran cond sub pod time code
1             package Search::Elasticsearch::Role::Client::Async::Simple::Direct;
2              
3 7     7   59971 use Moo::Role;
  7         31573  
  7         59  
4              
5 7     7   3532 use Package::Stash ();
  7         7277  
  7         117  
6              
7 7     7   1002 use namespace::clean;
  7         13945  
  7         56  
8              
9             with 'Search::Elasticsearch::Role::Client::Async::Simple';
10             with 'Search::Elasticsearch::Role::Client::Direct';
11              
12              
13             sub _install_api {
14 6     6   16 my ($cls, $grp) = @_;
15              
16 6         31 my $defs = $cls->api;
17 6         83 my $pkg = Package::Stash->new($cls);
18              
19 6 100       129 my $re = $grp ? qr/$grp\./ : qr//;
20              
21 6         138 for my $act (keys(%$defs)) {
22 624         1858 my ($name) = $act =~ /^$re([^.]+)$/;
23              
24 624 100       1458 next unless $name;
25 104 100       588 next if $pkg->has_symbol('&' . $name);
26              
27 103         159 my %def = (name => $name, %{$defs->{$act}});
  103         732  
28              
29             $pkg->add_symbol(
30             '&' . $name => sub {
31 0     0     shift()->perform_request(\%def, @_);
32 0           return;
33             }
34 103         1199 );
35             }
36             }
37              
38              
39             1;
40              
41              
42             __END__