Passing/Filter/Decoder/JSON.pm

filter: Statementstmt 100% 22 / 22 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 100% 33 / 33 SCAR 6.9
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Passing/Filter/Encoder/Gzip.pm ↑ Summary Passing/Filter/T.pm »
1 package Message::Passing::Filter::Decoder::JSON;
2 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use JSON::MaybeXS qw( decode_json );
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Message::Passing::Exception::Decoding;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 with qw/
9 Message::Passing::Role::Filter
10 Message::Passing::Role::HasErrorChain
11 /;
12  
13 sub filter {
14 4 ▶ my ($self, $message) = @_;
Subroutine filter: called CC=1 SCAR=0.0
Pod documented
15 try {
16 4 ▶ ref($message) ? $message : decode_json( $message )
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
ref $message ? : 1 3 4
17 }
18 catch {
19 1 ▶ $self->error->consume(Message::Passing::Exception::Decoding->new(
Subroutine __ANON__: called CC=1 SCAR=0.0
20 exception => $_,
21 packed_data => $message,
22 ));
23 1 return; # Explicit return undef
24 4 };
25 }
26  
27 4 1;
28  
29 =head1 NAME
30  
31 Message::Passing::Role::Filter::Decoder::JSON
32  
33 =head1 DESCRIPTION
34  
35 Decodes string messages from JSON into data structures.
36  
37 =head1 ATTRIBUTES
38  
39 =head1 METHODS
40  
41 =head2 filter
42  
43 JSON decodes a message supplied as a parameter.
44  
45 =head1 SEE ALSO
46  
47 =over
48  
49 =item L<Message::Passing>
50  
51 =item L<Message::Passing::Manual::Concepts>
52  
53 =back
54  
55 =head1 SPONSORSHIP
56  
57 This module exists due to the wonderful people at Suretec Systems Ltd.
58 <http://www.suretecsystems.com/> who sponsored its development for its
59 VoIP division called SureVoIP <http://www.surevoip.co.uk/> for use with
60 the SureVoIP API -
61 <http://www.surevoip.co.uk/support/wiki/api_documentation>
62  
63 =head1 AUTHOR, COPYRIGHT AND LICENSE
64  
65 See L<Message::Passing>.
66  
67 =cut
68  
« Passing/Filter/Encoder/Gzip.pm ↑ Summary Passing/Filter/T.pm »