[Jifty-commit] r5208 - in Jifty-DBI/trunk: lib/Jifty/DBI/Filter

Jifty commits jifty-commit at lists.jifty.org
Mon Mar 10 21:45:17 EDT 2008


Author: sartak
Date: Mon Mar 10 21:45:16 2008
New Revision: 5208

Added:
   Jifty-DBI/trunk/lib/Jifty/DBI/Filter/URI.pm
Modified:
   Jifty-DBI/trunk/   (props changed)
   Jifty-DBI/trunk/Makefile.PL

Log:
 r52485 at onn:  sartak | 2008-03-10 21:45:09 -0400
 Jifty::DBI::Filter::URI


Modified: Jifty-DBI/trunk/Makefile.PL
==============================================================================
--- Jifty-DBI/trunk/Makefile.PL	(original)
+++ Jifty-DBI/trunk/Makefile.PL	Mon Mar 10 21:45:16 2008
@@ -41,6 +41,10 @@
         'Time::Duration' => '',
         'Time::Duration::Parse' => '0.05',
     ],
+    'URI filter' => [
+        -default => 1,
+        'URI' => '',
+    ],
 );
 auto_install();
 &WriteAll;

Added: Jifty-DBI/trunk/lib/Jifty/DBI/Filter/URI.pm
==============================================================================
--- (empty file)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Filter/URI.pm	Mon Mar 10 21:45:16 2008
@@ -0,0 +1,55 @@
+#!/usr/bin/env perl
+package Jifty::DBI::Filter::URI;
+use strict;
+use warnings;
+
+use base 'Jifty::DBI::Filter';
+use URI;
+
+=head1 NAME
+
+Jifty::DBI::Filter::URI - Encodes uniform resource identifiers
+
+=head1 DESCRIPTION
+
+=head2 encode
+
+If the value is a L<URI>, encode it to its string
+form. Otherwise, do nothing.
+
+=cut
+
+sub encode {
+    my $self = shift;
+
+    my $value_ref = $self->value_ref;
+    return unless ref $$value_ref and $$value_ref->isa('URI');
+
+    $$value_ref = $$value_ref->as_string;
+    return 1;
+}
+
+=head2 decode
+
+If value is defined, then decode it using
+L<URI/as_string>, otherwise do nothing.
+
+=cut
+
+sub decode {
+    my $self = shift;
+
+    my $value_ref = $self->value_ref;
+    return unless defined $$value_ref and length $$value_ref;
+
+    $$value_ref = URI->new($$value_ref);
+}
+
+=head1 SEE ALSO
+
+L<Jifty::DBI::Filter>, L<URI>
+
+=cut
+
+1;
+


More information about the Jifty-commit mailing list