Re: [CDBI] Delay Inflate
[prev]
[thread]
[next]
[Date index for 2006/01/07]
Oh, who can catch my dumb mistake.
Trying another approach overriding get() instead.
This is kind of ugly, but it generates:
Can't call method "time_zone" without a package or object reference
because $item->location is not returning an object, just the value.
sub get {
my ( $item, @cols ) = @_;
my @values = $item->SUPER::get( @cols );
for my $i (0..@values-1) {
my $col = $cols[$i];
next unless $col =~ /_time$/;
next if $item->{$col . '_zoneset'}++; # ouch
$values[$i]->set_time_zone( $item->location->time_zone->name );
$item->_attribute_store( $col, $values[$i] );
}
return @values;
}
Yet, overriding the accessor name in my previous post works. Isn't
the accessor just a thin wrapper around get()?
sub my_time_column { shift->_set_time_zone( 'my_time_column', @_ ) }
sub _set_time_zone {
my ( $item, $col, $dt ) = @_;
return $item->set( $col, $dt ) if defined $dt;
$dt = $item->get($col);
return $dt if $item->{$col . '_zoneset'}++; # ouch
$dt->set_time_zone( $item->location->time_zone->name );
$item->_attribute_store( $col, $dt ); # don't want t flag as updated
return $dt;
}
--
Bill Moseley
moseley@xxxx.xxx
_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
|
|
Re: [CDBI] Delay Inflate
Bill Moseley 17:52 on 07 Jan 2006
|