File Coverage

lib/Beekeeper/JSONRPC/Request.pm
Criterion Covered Total %
statement 9 17 52.9
branch 4 4 100.0
condition n/a
subroutine 5 12 41.6
pod 9 10 90.0
total 27 43 62.7


line stmt bran cond sub pod time code
1             package Beekeeper::JSONRPC::Request;
2              
3 11     11   81 use strict;
  11         31  
  11         324  
4 11     11   62 use warnings;
  11         22  
  11         3862  
5              
6             our $VERSION = '0.08';
7              
8              
9             sub new {
10 0     0 0 0 my $class = shift;
11 0         0 bless {
12             jsonrpc => '2.0',
13             method => undef,
14             params => undef,
15             id => undef,
16             @_
17             }, $class;
18             }
19              
20 0     0 1 0 sub method { $_[0]->{method} }
21 0     0 1 0 sub params { $_[0]->{params} }
22 0     0 1 0 sub id { $_[0]->{id} }
23              
24             sub response {
25 2     2 1 623 $_[0]->{_response};
26             }
27              
28             sub result {
29             # Shortcut for $req->response->result
30 12 100   12 1 6015 return ($_[0]->{_response}) ? $_[0]->{_response}->{result} : undef;
31             }
32              
33             sub success {
34             # Shortcut for $req->response->success
35 2 100   2 1 16 return ($_[0]->{_response}) ? $_[0]->{_response}->success : undef;
36             }
37              
38             sub mqtt_properties {
39 0     0 1   $_[0]->{_mqtt_properties};
40             }
41              
42             sub async_response {
43 0     0 1   $_[0]->{_async_response} = 1;
44             }
45              
46             sub send_response {
47 0     0 1   $_[0]->{_worker}->__send_response(@_);
48             }
49              
50             1;
51              
52             __END__