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   34 use strict;
  4         9  
  4         132  
3 4     4   26 use warnings;
  4         9  
  4         113  
4 4     4   23 use utf8;
  4         11  
  4         44  
5 4     4   132 use feature qw/state/;
  4         14  
  4         898  
6              
7             sub import {
8 57     57   386     my ($class, %rules) = @_;
9 57         155     my $caller = caller;
10              
11 57         305     while (my ($method_name, $rule) = each %rules) {
12 284         993         (my $path = $method_name) =~ s/_([a-z])/\u$1/g;
13 284         788         my $method = sprintf '%s::%s', $caller, $method_name;
14              
15 4     4   34         no strict 'refs';
  4         8  
  4         693  
16                     *$method = sub {
17 100     100   38542             state $v = Data::Validator->new(%$rule)->with('Method', 'AllowExtra');
18 100         186130             my ($self, $args, %extra) = $v->validate(@_);
19 100         11095             return $self->request($path, {%$args, %extra});
20 284         7866         };
21                 }
22             }
23              
24             1;
25              
26