Auto-create netaddr::ip objects from columns.
Load this component and declare columns as \s-1IP\s0 addresses with the appropriate format.
package Host; _\|_PACKAGE_\|_->load_components(qw/InflateColumn::IP Core/); _\|_PACKAGE_\|_->add_columns( ip_address => { data_type => 'bigint', is_nullable => 0, is_ip => 1, ip_format => 'numeric', } ); package Network; _\|_PACKAGE_\|_->load_components(qw/InflateColumn::IP Core/); _\|_PACKAGE_\|_->add_columns( address => { data_type => 'varchar', size => 18 is_nullable => 0, is_ip => 1, ip_format => 'cidr', } );
Then you can treat the specified column as a NetAddr::IP object.
print 'IP address: ', $host->ip_address->addr; print 'Address type: ', $host->ip_address->iptype;
DBIx::Class::InflateColumn::IP supports a limited amount of auto-detection of the format based on the column type. If the type begins with \*(C`int\*(C' or \*(C`bigint\*(C', it's assumed to be numeric, while \*(C`inet\*(C' and \*(C`cidr\*(C' (as used by e.g. PostgreSQL) are assumed to be \*(C`cidr\*(C' format.
Gets/sets the address class that the columns should be inflated into. The default class is NetAddr::IP.
Gets/sets the name of the method used to deflate the address for the database. This must return a value suitable for \*(C`$ip_class-\*(C'new(); The default format is \*(C`addr\*(C', which returns the address in dotted-quad notation. See \*(L"Methods\*(R" in NetAddr::IP for suitable values.
Chains with \*(L"register_column\*(R" in DBIx::Class::Row, and sets up \s-1IP\s0 address columns appropriately. This would not normally be called directly by end users.
Dagfinn Ilmari Mannsa\*oker, \*(C`<ilmari at ilmari.org>\*(C'
Please report any bugs or feature requests to \*(C`bug-dbix-class-inflatecolumn-ip at rt.cpan.org\*(C', or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Class-InflateColumn-IP <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Class-InflateColumn-IP>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc DBIx::Class::InflateColumn::IP
You can also look for information at:
AnnoCPAN: Annotated \s-1CPAN\s0 documentation http://annocpan.org/dist/DBIx-Class-InflateColumn-IP <http://annocpan.org/dist/DBIx-Class-InflateColumn-IP>
\s-1CPAN\s0 Ratings http://cpanratings.perl.org/d/DBIx-Class-InflateColumn-IP <http://cpanratings.perl.org/d/DBIx-Class-InflateColumn-IP>
\s-1RT:\s0 \s-1CPAN\s0's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class-InflateColumn-IP <http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class-InflateColumn-IP>
Search \s-1CPAN\s0 http://search.cpan.org/dist/DBIx-Class-InflateColumn-IP <http://search.cpan.org/dist/DBIx-Class-InflateColumn-IP>
DBIx::Class, NetAddr::IP
Copyright 2007 Dagfinn Ilmari Mannsa\*oker, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.