File Coverage

blib/lib/URL/Signature/Query.pm
Criterion Covered Total %
statement 25 27 92.5
branch 3 6 50.0
condition n/a
subroutine 7 8 87.5
pod 4 4 100.0
total 39 45 86.6


line stmt bran cond sub pod time code
1             package URL::Signature::Query;
2              
3 1     1   942 use strict;
  1         2  
  1         55  
4 1     1   5 use warnings;
  1         3  
  1         55  
5 1     1   6 use parent 'URL::Signature';
  1         2  
  1         9  
6 1     1   76 use Params::Util qw( _STRING );
  1         2  
  1         404  
7              
8             our $VERSION = '0.03';
9              
10             sub new {
11 0     0 1 0 my ($class, %attrs) = @_;
12 0         0 return $class->SUPER::new( %attrs, format => 'query' );
13             }
14              
15              
16             sub BUILD {
17 1     1 1 3 my $self = shift;
18 1 50       12 $self->{'as'} = 'k' unless exists $self->{'as'};
19 1 50       6 Carp::croak(q[in 'query' format, 'as' needs to be a valid string])
20             unless defined _STRING($self->{'as'});
21 1         3 return;
22             }
23              
24              
25             sub extract {
26 2     2 1 4 my ($self, $uri) = @_;
27 2         8 my $code = $uri->query_param_delete( $self->{as} );
28 2         286 return ($code, $uri);
29             }
30              
31              
32             sub append {
33 2     2 1 5 my ($self, $uri, $code) = @_;
34 2         4 my $varname = $self->{as};
35 2         16 my $code_check = $uri->query_param_delete($varname);
36 2 50       88 Carp::croak("variable '$varname' (reserved for auth code) found in path")
37             if $code_check;
38              
39 2         13 $uri->query_param_append( $varname => $code );
40 2         205 return $uri;
41             }
42              
43              
44             42;
45             __END__