[Bast-commits] r3368 - in trunk/DBIx-Class-InflateColumn-IP: .
lib/DBIx/Class/InflateColumn
ilmari at dev.catalyst.perl.org
ilmari at dev.catalyst.perl.org
Wed May 23 18:42:04 GMT 2007
Author: ilmari
Date: 2007-05-23 18:42:03 +0100 (Wed, 23 May 2007)
New Revision: 3368
Modified:
trunk/DBIx-Class-InflateColumn-IP/Makefile.PL
trunk/DBIx-Class-InflateColumn-IP/README
trunk/DBIx-Class-InflateColumn-IP/lib/DBIx/Class/InflateColumn/IP.pm
Log:
Initial implementation for integer columns only.
Use NetAddr::IP instead of Net::IP.
Modified: trunk/DBIx-Class-InflateColumn-IP/Makefile.PL
===================================================================
--- trunk/DBIx-Class-InflateColumn-IP/Makefile.PL 2007-05-23 14:39:42 UTC (rev 3367)
+++ trunk/DBIx-Class-InflateColumn-IP/Makefile.PL 2007-05-23 17:42:03 UTC (rev 3368)
@@ -8,7 +8,7 @@
all_from 'lib/DBIx/Class/InflateColumn/IP.pm';
requires 'DBIx::Class' => 0.07005;
-requires 'Net::IP';
+requires 'NetAddr::IP';
tests 't/*.t';
clean_files 'DBIx-Class-InflateColumn-IP-*';
Modified: trunk/DBIx-Class-InflateColumn-IP/README
===================================================================
--- trunk/DBIx-Class-InflateColumn-IP/README 2007-05-23 14:39:42 UTC (rev 3367)
+++ trunk/DBIx-Class-InflateColumn-IP/README 2007-05-23 17:42:03 UTC (rev 3368)
@@ -1,6 +1,6 @@
NAME
- DBIx::Class::InflateColumn::IP - Auto-create Net::IP objects from
- columns.
+ DBIx::Class::InflateColumn::IP - Auto-create NetAddr::IP objects from
+ integer columns.
VERSION
Version 0.01
@@ -61,7 +61,7 @@
<http://search.cpan.org/dist/DBIx-Class-InflateColumn-IP>
SEE ALSO
- DBIx::Class, Net::IP
+ DBIx::Class, NetAddr::IP
COPYRIGHT & LICENSE
Copyright 2007 Dagfinn Ilmari Mannsåker, all rights reserved.
Modified: trunk/DBIx-Class-InflateColumn-IP/lib/DBIx/Class/InflateColumn/IP.pm
===================================================================
--- trunk/DBIx-Class-InflateColumn-IP/lib/DBIx/Class/InflateColumn/IP.pm 2007-05-23 14:39:42 UTC (rev 3367)
+++ trunk/DBIx-Class-InflateColumn-IP/lib/DBIx/Class/InflateColumn/IP.pm 2007-05-23 17:42:03 UTC (rev 3368)
@@ -2,10 +2,11 @@
use warnings;
use strict;
+use NetAddr::IP;
=head1 NAME
-DBIx::Class::InflateColumn::IP - Auto-create Net::IP objects from columns.
+DBIx::Class::InflateColumn::IP - Auto-create NetAddr::IP objects from columns.
=head1 VERSION
@@ -17,7 +18,7 @@
=head1 SYNOPSIS
-Load this component and declare the relevant columns as IP addresses.
+Load this component and declare integer columns as IP addresses.
package Host;
__PACKAGE__->load_components(qw/InflateColumn::IP/);
@@ -42,6 +43,22 @@
columns appropriately. This would not normally be called directly by end
users.
+=cut
+
+sub register_column {
+ my ($self, $column, $info, @rest) = @_;
+ $self->next::method($column, $info, @rest);
+
+ return unless defined $info->{'is_ip'};
+
+ $self->inflate_column(
+ $column => {
+ inflate => sub { return NetAddr::IP->new(shift); },
+ deflate => sub { return scalar shift->numeric; },
+ }
+ );
+}
+
=head1 AUTHOR
Dagfinn Ilmari Mannsåker, C<< <ilmari at ilmari.org> >>
@@ -84,7 +101,7 @@
=head1 SEE ALSO
-L<DBIx::Class>, L<Net::IP>
+L<DBIx::Class>, L<NetAddr::IP>
=head1 COPYRIGHT & LICENSE
More information about the Bast-commits
mailing list