| 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
| |||||||||||
| 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
| |||||||||||
| 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; | |||||||||