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   30 use strict;
  4         9  
  4         172  
3 4     4   22 use warnings;
  4         8  
  4         206  
4 4     4   24 use utf8;
  4         8  
  4         33  
5 4     4   209 use feature qw/state/;
  4         26  
  4         1365  
6              
7             sub import {
8 57     57   458 my ($class, %rules) = @_;
9 57         200 my $caller = caller;
10              
11 57         2202 while (my ($method_name, $rule) = each %rules) {
12 284         1002 (my $path = $method_name) =~ s/_([a-z])/\u$1/g;
13 284         538 my $method = sprintf '%s::%s', $caller, $method_name;
14              
15 4     4   35 no strict 'refs';
  4         8  
  4         968  
16             *$method = sub {
17 100     100   71115 state $v = Data::Validator->new(%$rule)->with('Method', 'AllowExtra');
18 100         262371 my ($self, $args, %extra) = $v->validate(@_);
19 100         15960 return $self->request($path, {%$args, %extra});
20 284         16348 };
21             }
22             }
23              
24             1;
25