WebSocket/Response.pm

filter: Statementstmt 66.6% 26 / 39 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 53.8% 7 / 13 Podpod 0.0% 0 / 4 totaltotal 58.9% 33 / 56 CC 1 SCAR 3.8
CC
1
Cov
67%
__ANON__
2.0
is_success
2.0
items
2.0
CRAP 1.5
« WebSocket/Role/WebSocketResult.pm ↑ Summary WebSocket/Result/Failure.pm »
1 1 ▶use v5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package JMAP::Tester::WebSocket::Response 0.006;
5 # ABSTRACT: what you get in reply to a succesful JMAP request
6  
7 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # We can't use 'sub sentencebroker;' as a stub here as it conflicts
10 # with older Role::Tiny versions (2.000006, 2.000008, and others).
11 # With the stub, we'd see this error during compilation:
12 #
13 # Can't use string ("-1") as a symbol ref while "strict refs" in use at
14 # /usr/share/perl5/Role/Tiny.pm line 382
15 #
16 # We could pin a newer Role::Tiny version but this fix is easy enough
17  
18 has sentence_broker => (
19 is => 'ro',
20 lazy => 1,
21 init_arg => undef,
22 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 0 my ($self) = @_;
24 0 JMAP::Tester::SentenceBroker->new({ response => $self });
25 },
26 1 );
27  
28  
29 1 with 'JMAP::Tester::Role::SentenceCollection', 'JMAP::Tester::WebSocket::Role::WebSocketResult';
30  
31 1 ▶use JMAP::Tester::Response::Sentence;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 1 ▶use JMAP::Tester::Response::Paragraph;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 1 ▶use JMAP::Tester::SentenceBroker;
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 #pod =head1 OVERVIEW
38 #pod
39 #pod A JMAP::Tester::WebSocket::Response object represents the successful response to a JMAP
40 #pod call. It is a successful L<JMAP::Tester::Result>.
41 #pod
42 #pod A Response is used mostly to contain the responses to the individual methods
43 #pod passed in the request.
44 #pod
45 #pod =cut
46  
47 0 ▶sub is_success { 1 }
Subroutine is_success: not called CC=1 SCAR=6.9
Pod undocumented
48  
49 1 has items => (
50 is => 'bare',
51 reader => '_items',
52 required => 1,
53 );
54  
55 1 has wrapper_properties => (
56 is => 'ro',
57 );
58  
59 0 ▶sub items { @{ $_[0]->_items } }
Subroutine items: not called CC=1 SCAR=6.9
Pod undocumented
60  
61 sub add_items {
62 $_[0]->sentence_broker->abort("can't add items to " . __PACKAGE__);
63 }
64  
65 0 ▶sub default_diagnostic_dumper {
Subroutine default_diagnostic_dumper: not called CC=1 SCAR=6.9
Pod undocumented
66 0 state $default = do {
67 0 require JSON::MaybeXS;
68 0 state $json = JSON::MaybeXS->new->utf8->convert_blessed->pretty->canonical;
69 0 ▶ sub { $json->encode($_[0]); }
Subroutine __ANON__: not called CC=1 SCAR=6.9
70 0 };
71  
72 0 return $default;
73 }
74  
75 1 has _diagnostic_dumper => (
76 is => 'ro',
77 builder => 'default_diagnostic_dumper',
78 init_arg => 'diagnostic_dumper',
79 );
80  
81 0 ▶sub dump_diagnostic {
Subroutine dump_diagnostic: not called CC=1 SCAR=6.9
Pod undocumented
82 0 my ($self, $value) = @_;
83 0 $self->_diagnostic_dumper->($value);
84 }
85  
86 1 1;
87  
88 __END__
« WebSocket/Role/WebSocketResult.pm ↑ Summary WebSocket/Result/Failure.pm »