Dagfinn Ilmari Manns=C3=A5ker wrote: > Hi all, >=20 > I've just hacked up my first ever Perl module headed for CPAN: > DBIx::Class::InflateColumn:IP, which inflates IP address columns to > NetAddr::IP objects. Currently it only supports addresses stored as > integers in the database; netmask support and more flexible storage > format options are on the TODO list. >=20 > Without further ado, Here's the SYNOPSIS section of the POD: >=20 > Load this component and declare integer columns as IP addresses.=
>=20
> package Host;
> __PACKAGE__->load_components(qw/InflateColumn::IP Core/);
> __PACKAGE__->add_columns(
> ip_address =3D> {
> data_type =3D> =E2=80=99integer=E2=80=99,
> is_nullable =3D> 0,
> is_ip =3D> 1,
> }
> );
>=20
> Then you can treat the specified column as a NetAddr::IP object.=
>=20
> print =E2=80=99IP address: =E2=80=99, $host->ip_address->ip;=
> print =E2=80=99Address type: =E2=80=99, $host->ip_address->i=
ptype;
>=20
>=20
> While I wait for my PAUSE id application to come through I would be
> delighed if anyone would care to take a look at the code and comment on=
> any mistakes I might have made. It can be checked out from SVN (thanks
> Matt!) at
>=20
> <http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class-InflateColumn=
-IP>
>=20
> or downloaded from
>=20
> <http://ilmari.org/perl/DBIx-Class-InflateColumn-IP-0.01.tar.gz>
>=20
Nice work. Welcome to the InflateColumn module owners club. :-)
Just one carg cult brainwashed by mst nit:
our $VERSION =3D '0.01';
Join the cult. Use the long version numbers (0.01000).
I would also mention in the does, that an is_ip column doesn't have to
be integer. It can also be a varchar/char containing: '1.2.3.4', or
anything that IP->new supports...which appears to be a lot.
Maybe I'm just in a verbose mood this evening.
-=3DChris
signature.asc
Description: OpenPGP digital signature
_______________________________________________ List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class Wiki: http://dbix-class.shadowcatsystems.co.uk/ IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/ Searchable Archive: http://www.mail-archive.com/[email protected]/
