| 1 | package RPC::ExtDirect::Request::PollHandler; | ||||||||||
| 2 | |||||||||||
| 3 | # This private class implements overrides for Request | ||||||||||
| 4 | # to be used with EventProvider | ||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | no warnings 'uninitialized'; ## no critic | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 2 | ▶ | use base 'RPC::ExtDirect::Request'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | ### PUBLIC CLASS METHOD (CONSTRUCTOR) ### | ||||||||||
| 13 | # | ||||||||||
| 14 | # Initializes new instance of RPC::ExtDirect::Request | ||||||||||
| 15 | # | ||||||||||
| 16 | |||||||||||
| 17 | sub new { | ||||||||||
| 18 | 9 | ▶ | my ($class, $arg) = @_; | ||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||
| 19 | |||||||||||
| 20 | 9 | my $self = $class->SUPER::new($arg); | |||||||||
| 21 | |||||||||||
| 22 | # We can't return exceptions from poll handler anyway | ||||||||||
| 23 | 9 | ▶ | return $self->{message} ? undef : $self; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | ▶ | return undef; ## no critic | ||||||||
|
Subroutine
check_arguments: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | ### PUBLIC INSTANCE METHOD ### | ||||||||||
| 39 | # | ||||||||||
| 40 | # Return Events data extracted | ||||||||||
| 41 | # | ||||||||||
| 42 | |||||||||||
| 43 | sub result { | ||||||||||
| 44 | 9 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
result: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 45 | |||||||||||
| 46 | 9 | my $events = $self->{result}; | |||||||||
| 47 | |||||||||||
| 48 | # A hook can return something that is not an event list | ||||||||||
| 49 | 9 | ▶ | $events = [] unless 'ARRAY' eq ref $events; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | |||||||||||
| 51 | 9 | return map { $_->result } @$events; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | ############## PRIVATE METHODS BELOW ############## | ||||||||||
| 55 | |||||||||||
| 56 | ### PRIVATE INSTANCE METHOD ### | ||||||||||
| 57 | # | ||||||||||
| 58 | # Handles errors | ||||||||||
| 59 | # | ||||||||||
| 60 | |||||||||||
| 61 | sub _set_error { | ||||||||||
| 62 | 2 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
_set_error: called CC=1 SCAR=0.0
| |||||||||||
| 63 | |||||||||||
| 64 | 2 | $self->{result} = []; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 2 | 1; | |||||||||