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         10  
  4         138  
3 4     4   25 use warnings;
  4         11  
  4         118  
4 4     4   36 use utf8;
  4         9  
  4         28  
5 4     4   136 use feature qw/state/;
  4         9  
  4         884  
6              
7             sub import {
8 57     57   386 my ($class, %rules) = @_;
9 57         192 my $caller = caller;
10              
11 57         660 while (my ($method_name, $rule) = each %rules) {
12 284         934 (my $path = $method_name) =~ s/_([a-z])/\u$1/g;
13 284         797 my $method = sprintf '%s::%s', $caller, $method_name;
14              
15 4     4   31 no strict 'refs';
  4         10  
  4         673  
16             *$method = sub {
17 100     100   38297 state $v = Data::Validator->new(%$rule)->with('Method', 'AllowExtra');
18 100         184519 my ($self, $args, %extra) = $v->validate(@_);
19 100         10999 return $self->request($path, {%$args, %extra});
20 284         8177 };
21             }
22             }
23              
24             1;
25