[Dbix-class] new module: DBIx::Class::InflateColumn::IP

Christopher H. Laco claco at chrislaco.com
Thu May 24 04:03:43 GMT 2007


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20070523/2b329053/signature.pgp


More information about the Dbix-class mailing list