File Coverage

blib/lib/RPC/ExtDirect/Request/PollHandler.pm
Criterion Covered Total %
statement 23 23 100.0
branch 3 4 75.0
condition n/a
subroutine 8 8 100.0
pod 0 3 0.0
total 34 38 89.4


line stmt bran cond sub pod time code
1             package RPC::ExtDirect::Request::PollHandler;
2              
3             # This private class implements overrides for Request
4             # to be used with EventProvider
5              
6 2     2   8 use strict;
  2         2  
  2         52  
7 2     2   6 use warnings;
  2         2  
  2         311  
8 2     2   9 no warnings 'uninitialized'; ## no critic
  2         2  
  2         70  
9              
10 2     2   6 use base 'RPC::ExtDirect::Request';
  2         2  
  2         617  
11              
12             ### PUBLIC CLASS METHOD (CONSTRUCTOR) ###
13             #
14             # Initializes new instance of RPC::ExtDirect::Request
15             #
16              
17             sub new {
18 9     9 0 23 my ($class, $arg) = @_;
19            
20 9         31 my $self = $class->SUPER::new($arg);
21            
22             # We can't return exceptions from poll handler anyway
23 9 50       24 return $self->{message} ? undef : $self;
24             }
25              
26             ### PUBLIC INSTANCE METHOD ###
27             #
28             # Checks if method arguments are in order
29             #
30              
31             sub check_arguments {
32              
33             # There are no parameters to poll handlers
34             # so we return undef which means no error
35 9     9 0 11 return undef; ## no critic
36             }
37              
38             ### PUBLIC INSTANCE METHOD ###
39             #
40             # Return Events data extracted
41             #
42              
43             sub result {
44 9     9 0 8 my ($self) = @_;
45              
46 9         9 my $events = $self->{result};
47            
48             # A hook can return something that is not an event list
49 9 100       20 $events = [] unless 'ARRAY' eq ref $events;
50            
51 9         15 return map { $_->result } @$events;
  8         15  
52             }
53              
54             ############## PRIVATE METHODS BELOW ##############
55              
56             ### PRIVATE INSTANCE METHOD ###
57             #
58             # Handles errors
59             #
60              
61             sub _set_error {
62 2     2   3 my ($self) = @_;
63            
64 2         10 $self->{result} = [];
65             }
66              
67             1;