Commit | Line | Data |
3a889a03 |
1 | NAME |
2 | DBIx::Class::InflateColumn::IP - Auto-create NetAddr::IP objects from |
3 | columns. |
4 | |
5 | SYNOPSIS |
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 => 'integer', |
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 | |
3baacba6 |
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", it's assumed to be numeric, while "inet" and "cidr" |
40 | (as used by e.g. PostgreSQL) are assumed to be "cidr" format. |
41 | |
3a889a03 |
42 | METHODS |
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 | |
62 | AUTHOR |
3baacba6 |
63 | Dagfinn Ilmari Mannsåker, "<ilmari at ilmari.org>" |
3a889a03 |
64 | |
65 | BUGS |
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 | |
73 | SUPPORT |
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 | <http://annocpan.org/dist/DBIx-Class-InflateColumn-IP> |
82 | |
83 | * CPAN Ratings |
84 | <http://cpanratings.perl.org/d/DBIx-Class-InflateColumn-IP> |
85 | |
86 | * RT: CPAN's request tracker |
87 | <http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class-InflateColumn-I |
88 | P> |
89 | |
90 | * Search CPAN |
91 | <http://search.cpan.org/dist/DBIx-Class-InflateColumn-IP> |
92 | |
93 | SEE ALSO |
94 | DBIx::Class, NetAddr::IP |
95 | |
96 | COPYRIGHT & LICENSE |
3baacba6 |
97 | Copyright 2007 Dagfinn Ilmari Mannsåker, all rights reserved. |
3a889a03 |
98 | |
99 | This program is free software; you can redistribute it and/or modify it |
100 | under the same terms as Perl itself. |
101 | |