File Coverage

blib/lib/SQS/Worker/DecodeJson.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package SQS::Worker::DecodeJson;
2 5     5   2215 use Moose::Role;
  5         10  
  5         33  
3 5     5   23879 use JSON::MaybeXS;
  5         10  
  5         932  
4              
5              
6             around process_message => sub {
7             my ($orig, $self, $message) = @_;
8              
9             my $body;
10             eval {
11             $body = decode_json($message->Body)
12             };
13             if ($@) {
14             $self->log->error("Error decoding JSON body in message " . $message->ReceiptHandle . ": " . $@ . " for content " . $message->Body);
15             die $@;
16             } else {
17             if (ref($body) eq 'ARRAY'){
18             return $self->$orig(@$body);
19             } else {
20             return $self->$orig($body);
21             }
22             }
23             };
24              
25             1;