| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||
| 2 | package Jifty::DBI::Filter::URI; | ||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use base 'Jifty::DBI::Filter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use URI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | Jifty::DBI::Filter::URI - Encodes uniform resource identifiers | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =head2 encode | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | If the value is a L<URI>, encode it to its string | ||||||||||||||||||||||||||||
| 18 | form. Otherwise, do nothing. | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =cut | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | sub encode { | ||||||||||||||||||||||||||||
| 23 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
encode: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 3 | my $value_ref = $self->value_ref; | |||||||||||||||||||||||||||
| 26 | 3 | ▶ | return unless ref $$value_ref and $$value_ref->isa('URI'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $$value_ref and $$value_ref->isa("URI")
MC/DC50%1/2
ref $$value_ref and $$value_ref->isa("URI")
ref $$value_ref
$$value_ref->isa("URI")
Truth table66%2/3
A and B
A= ref $$value_refB= $$value_ref->isa("URI")
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 1 | $$value_ref = $$value_ref->as_string; | |||||||||||||||||||||||||||
| 29 | 1 | return 1; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =head2 decode | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | If value is defined, then decode it using | ||||||||||||||||||||||||||||
| 35 | L<URI/as_string>, otherwise do nothing. | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | =cut | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | sub decode { | ||||||||||||||||||||||||||||
| 40 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
decode: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 3 | my $value_ref = $self->value_ref; | |||||||||||||||||||||||||||
| 43 | 3 | ▶ | return unless defined $$value_ref and length $$value_ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $$value_ref and length $$value_ref
MC/DC50%1/2
defined $$value_ref and length $$value_ref
defined $$value_ref
length $$value_ref
Truth table66%2/3
A and B
A= defined $$value_refB= length $$value_ref
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 2 | $$value_ref = URI->new($$value_ref); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | L<Jifty::DBI::Filter>, L<URI> | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =cut | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 1 | 1; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||