Hector/Response.pm

filter: Statementstmt 90.3% 28 / 31 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 88.6% 39 / 44 CC 3 SCAR 4.8
CC
3
Cov
86%
new
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.6
« Hector/Response/NotModified.pm ↑ Summary Hector/Response/Base.pm »
1 #factory response object
2 package PSGI::Hector::Response;
3  
4 =pod
5  
6 =head1 NAME
7  
8 PSGI::Hector::Response - Page response class
9  
10 =head1 SYNOPSIS
11  
12 =head1 DESCRIPTION
13  
14 Factory class for creating response objects.
15  
16 =head1 METHODS
17  
18 =cut
19  
20 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 #########################################################
23  
24 =pod
25  
26 =head2 new($hector, $plugin)
27  
28 Constructor, a factory method that will return an instance of the requested response plugin.
29  
30 If the response is not modified from the client's provided Etag header an instance of L<PSGI::Hector::Response::NotModified>
31 will be returned instead.
32  
33 =cut
34  
35 #########################################################
36 8 ▶sub new{
Subroutine new: called CC=3 SCAR=11.2
Pod documented
37 8 my($class, $hector, $plugin) = @_;
38 8 ▶ if($plugin){
Branch: 1 branch
BranchTrueFalseTotal
if ($plugin) { } 8 0 8
39 8 ▶ eval "use $plugin;"; #should do this a better way
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
40 8 ▶ if(!$@){ #plugin loaded ok
Branch: 1 branch
BranchTrueFalseTotal
if (not $@) { } 8 0 8
41 8 my $self = $plugin->new($hector);
42 8 return $self;
43 }
44 else{
45 0 die("Plugin load problem: $@");
46 }
47 }
48 else{
49 0 die("No plugin given");
50 }
51 0 return undef;
52 }
53 #########################################################
54 =pod
55  
56 =head1 Notes
57  
58 =head1 Author
59  
60 MacGyveR <dumb@cpan.org>
61  
62 Development questions, bug reports, and patches are welcome to the above address.
63  
64 =head1 See Also
65  
66 =head1 Copyright
67  
68 Copyright (c) 2017 MacGyveR. All rights reserved.
69  
70 This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
71  
72 =cut
73  
74 ##########################################
75 5 return 1;
« Hector/Response/NotModified.pm ↑ Summary Hector/Response/Base.pm »