File Coverage

blib/lib/Mackerel/Webhook/Receiver/Declare.pm
Criterion Covered Total %
statement 18 18 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 26 28 92.8


line stmt bran cond sub pod time code
1             package Mackerel::Webhook::Receiver::Declare;
2 1     1   72068 use strict;
  1         2  
  1         24  
3 1     1   5 use warnings;
  1         2  
  1         26  
4              
5 1     1   458 use Mackerel::Webhook::Receiver;
  1         3  
  1         29  
6 1     1   5 use parent 'Exporter';
  1         2  
  1         7  
7              
8             our @EXPORT = qw/receiver on/;
9              
10             our $_RECEIVER;
11             sub receiver(&) {
12 1     1 0 9 my $code = shift;
13 1         11 local $_RECEIVER = Mackerel::Webhook::Receiver->new;
14 1         9 $code->();
15 1         3 $_RECEIVER;
16             }
17              
18             sub on($;$) {
19 3 100   3 0 1512 die 'not in receiver block' unless $_RECEIVER;
20 2         7 $_RECEIVER->on(@_);
21             }
22              
23             1;
24             __END__