README
1NAME
2 DBIx::Class::InflateColumn::IP - Auto-create NetAddr::IP objects from
3 columns.
4
5SYNOPSIS
6 Load this component and declare columns as IP addresses with the
7 appropriate format.
8
9 package Host;
10 __PACKAGE__->load_components(qw/InflateColumn::IP Core/);
11 __PACKAGE__->add_columns(
12 ip_address => {
13 data_type => 'bigint',
14 is_nullable => 0,
15 is_ip => 1,
16 ip_format => 'numeric',
17 }
18 );
19
20 package Network;
21 __PACKAGE__->load_components(qw/InflateColumn::IP Core/);
22 __PACKAGE__->add_columns(
23 address => {
24 data_type => 'varchar',
25 size => 18
26 is_nullable => 0,
27 is_ip => 1,
28 ip_format => 'cidr',
29 }
30 );
31
32 Then you can treat the specified column as a NetAddr::IP object.
33
34 print 'IP address: ', $host->ip_address->addr;
35 print 'Address type: ', $host->ip_address->iptype;
36
37 DBIx::Class::InflateColumn::IP supports a limited amount of
38 auto-detection of the format based on the column type. If the type
39 begins with "int" or "bigint", it's assumed to be numeric, while "inet"
40 and "cidr" (as used by e.g. PostgreSQL) are assumed to be "cidr" format.
41
42METHODS
43 ip_class
44 Arguments: $class
45
46 Gets/sets the address class that the columns should be inflated into.
47 The default class is NetAddr::IP.
48
49 ip_format
50 Arguments: $format
51
52 Gets/sets the name of the method used to deflate the address for the
53 database. This must return a value suitable for "$ip_class-"new(); The
54 default format is "addr", which returns the address in dotted-quad
55 notation. See "Methods" in NetAddr::IP for suitable values.
56
57 register_column
58 Chains with "register_column" in DBIx::Class::Row, and sets up IP
59 address columns appropriately. This would not normally be called
60 directly by end users.
61
62AUTHOR
63 Dagfinn Ilmari Mannsåker, "<ilmari at ilmari.org>"
64
65BUGS
66 Please report any bugs or feature requests to
67 "bug-dbix-class-inflatecolumn-ip at rt.cpan.org", or through the web
68 interface at
69 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Class-InflateColumn
70 -IP>. I will be notified, and then you'll automatically be notified of
71 progress on your bug as I make changes.
72
73SUPPORT
74 You can find documentation for this module with the perldoc command.
75
76 perldoc DBIx::Class::InflateColumn::IP
77
78 You can also look for information at:
79
80 * AnnoCPAN: Annotated CPAN documentation
81
82 <http://annocpan.org/dist/DBIx-Class-InflateColumn-IP>
83
84 * CPAN Ratings
85
86 <http://cpanratings.perl.org/d/DBIx-Class-InflateColumn-IP>
87
88 * RT: CPAN's request tracker
89
90 <http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class-InflateColumn-I
91 P>
92
93 * Search CPAN
94
95 <http://search.cpan.org/dist/DBIx-Class-InflateColumn-IP>
96
97SEE ALSO
98 DBIx::Class, NetAddr::IP
99
100COPYRIGHT & LICENSE
101 Copyright 2007 Dagfinn Ilmari Mannsåker, all rights reserved.
102
103 This program is free software; you can redistribute it and/or modify it
104 under the same terms as Perl itself.
105
106