in reply to Re: Re: Re: Re: Class::DBI - performing action on column before it is used or saved
in thread Class::DBI - performing action on column before it is used or saved
For IP addresses, I would have them inflate to a NetAddr::IP object:
use NetAddr::IP; __PACKAGE__->has_a( ip_addr => 'NetAddr::IP' inflate => sub { my $packed = shift; # Unpack the IP addr here into $ip and $netmask return NetAddr::IP->new( $ip, $netmask ); }, deflate => sub { my $addr = shift; # Take the NetAddr::IP instance and pack it # into $packed return $packed; }, );
Using Class::DBI = Good
Using Class::DBI with inflation of many fields to objects = Better (usually)
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
: () { :|:& };:
Note: All code is untested, unless otherwise stated
|
|---|