File Coverage

blib/lib/JMAP/Tester/Response.pm
Criterion Covered Total %
statement 30 30 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod 0 3 0.0
total 40 43 93.0


line stmt bran cond sub pod time code
1 2     2   26 use v5.20.0;
  2         7  
2              
3             package JMAP::Tester::Response 0.110;
4             # ABSTRACT: what you get in reply to a succesful JMAP request
5              
6 2     2   8 use Moo;
  2         4  
  2         8  
7 2     2   556 use experimental 'signatures';
  2         3  
  2         8  
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             default => sub {
23             my ($self) = @_;
24             JMAP::Tester::SentenceBroker->new({ response => $self });
25             },
26             );
27              
28             with 'JMAP::Tester::Role::SentenceCollection', 'JMAP::Tester::Role::HTTPResult';
29              
30 2     2   1416 use JMAP::Tester::Response::Sentence;
  2         6  
  2         75  
31 2     2   838 use JMAP::Tester::Response::Paragraph;
  2         6  
  2         91  
32 2     2   861 use JMAP::Tester::SentenceBroker;
  2         6  
  2         59  
33              
34 2     2   11 use namespace::clean;
  2         2  
  2         9  
35              
36             #pod =head1 OVERVIEW
37             #pod
38             #pod A JMAP::Tester::Response object represents the successful response to a JMAP
39             #pod request -- the kind where you've POSTed a JSON object with C. It
40             #pod is a successful L.
41             #pod
42             #pod A Response is used mostly to contain the responses to the individual methods
43             #pod passed in the request. For all of that interface, consult
44             #pod L.
45             #pod
46             #pod A Response is also a L, meaning it has a
47             #pod C method that returns an L object.
48             #pod
49             #pod =cut
50              
51 5     5 0 31 sub is_success { 1 }
52              
53             has items => (
54             is => 'bare',
55             reader => '_items',
56             required => 1,
57             );
58              
59             has wrapper_properties => (
60             is => 'ro',
61             );
62              
63 111     111 0 132 sub items ($self) { @{ $self->_items } }
  111         140  
  111         134  
  111         152  
  111         418  
64              
65             sub add_items ($self, @) {
66             $self->abort("can't add items to " . __PACKAGE__);
67             }
68              
69 13     13 0 14 sub default_diagnostics ($self) {
  13         15  
  13         13  
70 13         26 return [ 'Response sentences', [ $self->sentences ] ];
71             }
72              
73             1;
74              
75             __END__