File Coverage

blib/lib/HTTP/Throwable/Role/TextBody.pm
Criterion Covered Total %
statement 10 10 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 3 0.0
total 15 18 83.3


line stmt bran cond sub pod time code
1             package HTTP::Throwable::Role::TextBody 0.028;
2             our $AUTHORITY = 'cpan:STEVAN';
3              
4 5     5   3551 use Moo::Role;
  5         16  
  5         43  
5              
6 86     86 0 307 sub body { $_[0]->text_body }
7              
8             sub body_headers {
9 31     31 0 90 my ($self, $body) = @_;
10              
11             return [
12 31         148 'Content-Type' => 'text/plain',
13             'Content-Length' => length $body,
14             ];
15             }
16              
17 55     55 0 42735 sub as_string { $_[0]->body }
18              
19             requires 'text_body';
20              
21 5     5   2343 no Moo::Role; 1;
  5         11  
  5         24  
22              
23             =pod
24              
25             =encoding UTF-8
26              
27             =head1 NAME
28              
29             HTTP::Throwable::Role::TextBody - an exception with a plaintext body
30              
31             =head1 VERSION
32              
33             version 0.028
34              
35             =head1 OVERVIEW
36              
37             This is a very simple role, implementing the required C, C,
38             and C for L. In turn, it requires that a
39             C method be provided.
40              
41             When an HTTP::Throwable exception uses this role, its PSGI response will have a
42             C content type and will send the result of calling its C
43             method as the response body. It will also stringify to the text body.
44              
45             The role L can be useful to provide a
46             C method that issues the C as the body.
47              
48             =head1 PERL VERSION
49              
50             This library should run on perls released even a long time ago. It should work
51             on any version of perl released in the last five years.
52              
53             Although it may work on older versions of perl, no guarantee is made that the
54             minimum required version will not be increased. The version may be increased
55             for any reason, and there is no promise that patches will be accepted to lower
56             the minimum required perl.
57              
58             =head1 AUTHORS
59              
60             =over 4
61              
62             =item *
63              
64             Stevan Little
65              
66             =item *
67              
68             Ricardo Signes
69              
70             =back
71              
72             =head1 COPYRIGHT AND LICENSE
73              
74             This software is copyright (c) 2011 by Infinity Interactive, Inc.
75              
76             This is free software; you can redistribute it and/or modify it under
77             the same terms as the Perl 5 programming language system itself.
78              
79             =cut
80              
81             __END__