File Coverage

lib/PSGI/Hector/Response.pm
Criterion Covered Total %
statement 18 21 85.7
branch 2 4 50.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 26 31 83.8


line stmt bran cond sub pod time code
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     5   16 use strict;
  5         6  
  5         114  
21 5     5   15 use warnings;
  5         6  
  5         655  
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
31             will be returned instead.
32              
33             =cut
34              
35             #########################################################
36             sub new{
37 5     5 1 10 my($class, $hector, $plugin) = @_;
38 5 50       15 if($plugin){
39 5     4   256 eval "use $plugin;"; #should do this a better way
  4     1   762  
  4         8  
  4         91  
  1         5  
  1         2  
  1         15  
40 5 50       21 if(!$@){ #plugin loaded ok
41 5         20 my $self = $plugin->new($hector);
42 5         17 return $self;
43             }
44             else{
45 0         0 die("Plugin load problem: $@");
46             }
47             }
48             else{
49 0         0 die("No plugin given");
50             }
51 0         0 return undef;
52             }
53             #########################################################
54             =pod
55              
56             =head1 Notes
57              
58             =head1 Author
59              
60             MacGyveR
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             return 1;