File Coverage

blib/lib/WebService/Slack/WebApi/Generator.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 31 31 100.0


line stmt bran cond sub pod time code
1             package WebService::Slack::WebApi::Generator;
2 4     4   31 use strict;
  4         12  
  4         128  
3 4     4   22 use warnings;
  4         10  
  4         100  
4 4     4   23 use utf8;
  4         11  
  4         26  
5 4     4   103 use feature qw/state/;
  4         9  
  4         776  
6              
7             sub import {
8 57     57   371     my ($class, %rules) = @_;
9 57         157     my $caller = caller;
10              
11 57         293     while (my ($method_name, $rule) = each %rules) {
12 284         939         (my $path = $method_name) =~ s/_([a-z])/\u$1/g;
13 284         800         my $method = sprintf '%s::%s', $caller, $method_name;
14              
15 4     4   39         no strict 'refs';
  4         17  
  4         687  
16                     *$method = sub {
17 100     100   47003             state $v = Data::Validator->new(%$rule)->with('Method', 'AllowExtra');
18 100         183891             my ($self, $args, %extra) = $v->validate(@_);
19 100         10878             return $self->request($path, {%$args, %extra});
20 284         7921         };
21                 }
22             }
23              
24             1;
25              
26