Delivery/Provider/Scalar.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 75 CC 7 SCAR 33.7
CC
7
Cov
0%
new
56.0
BEGIN
2.0
image
2.0
CRAP 29.0
1 package Image::Delivery::Provider::Scalar;
2  
3 use strict;
4 use UNIVERSAL 'isa';
5 use base 'Image::Delivery::Provider';
6 use Digest::TransformPath ();
7  
8 use vars qw{$VERSION};
9 BEGIN {
10 $VERSION = '0.14';
11 }
12  
13  
14  
15  
16  
17 #####################################################################
18 # Constructor
19  
20 sub new {
21 my $class = shift;
22 my $image = ref $_[0] eq 'SCALAR' ? shift : return undef;
23 my %params = @_;
24  
25 # Create the object
26 my $self = bless {
27 image => $image,
28 }, $class;
29  
30 # Handle arguments
31 if ( isa($params{TransformPath}, 'Digest::TransformPath') ) {
32 $self->{TransformPath} = $params{TransformPath};
33 }
34 if ( defined $params{id} and length $params{id} ) {
35 $self->{id} = $params{id};
36 }
37 if ( defined $params{content_type} and length $params{content_type} ) {
38 $self->{content_type} = $params{content_type};
39 }
40 if ( defined $params{extension} and length $params{extension} ) {
41 $self->{extension} = $params{extension};
42 }
43  
44 # Are we allowed to use the image type passed
45 my $extension = $self->extension or return undef;
46 unless ( grep { $extension eq $_ } $self->filetypes ) {
47 # Unsupported file type
48 return undef;
49 }
50  
51 $self;
52 }
53  
54 sub image { $_[0]->{image} }
55  
56 1;