my $colinfo = $self->column_info($col);
- $self->throw_exception("InflateColumn does not work with FilterColumn")
- if $self->isa('DBIx::Class::FilterColumn') &&
- defined $colinfo->{_filter_info};
+ $self->throw_exception("InflateColumn can not be used on a column with a declared FilterColumn filter")
+ if defined $colinfo->{_filter_info} and $self->isa('DBIx::Class::FilterColumn');
$self->throw_exception("No such column $col to inflate")
unless $self->has_column($col);
return $value unless exists $info->{_inflate_info};
- my $inflate = $info->{_inflate_info}{inflate};
- $self->throw_exception("No inflator for $col") unless defined $inflate;
-
- return $inflate->($value, $self);
+ return (
+ $info->{_inflate_info}{inflate}
+ ||
+ $self->throw_exception("No inflator found for '$col'")
+ )->($value, $self);
}
sub _deflated_column {
return $value unless exists $info->{_inflate_info};
- my $deflate = $info->{_inflate_info}{deflate};
- $self->throw_exception("No deflator for $col") unless defined $deflate;
-
- return $deflate->($value, $self);
+ return (
+ $info->{_inflate_info}{deflate}
+ ||
+ $self->throw_exception("No deflator found for '$col'")
+ )->($value, $self);
}
=head2 get_inflated_column
sub get_inflated_column {
my ($self, $col) = @_;
+
$self->throw_exception("$col is not an inflated column")
unless exists $self->column_info($col)->{_inflate_info};
+
+ # we take care of keeping things in sync
return $self->{_inflated_column}{$col}
if exists $self->{_inflated_column}{$col};
=cut
sub set_inflated_column {
- my ($self, $col, $inflated) = @_;
- $self->set_column($col, $self->_deflated_column($col, $inflated));
+ my ($self, $col, $value) = @_;
+
+ $self->set_column($col, $self->_deflated_column($col, $value));
- if (length ref $inflated and ! is_literal_value($inflated) ) {
- $self->{_inflated_column}{$col} = $inflated;
+ if (length ref $value and ! is_literal_value($value) ) {
+ $self->{_inflated_column}{$col} = $value;
} else {
delete $self->{_inflated_column}{$col};
}
- return $inflated;
+ return $value;
}
=head2 store_inflated_column
=cut
sub store_inflated_column {
- my ($self, $col, $inflated) = @_;
+ my ($self, $col, $value) = @_;
- if (is_literal_value($inflated)) {
+ if (is_literal_value($value)) {
delete $self->{_inflated_column}{$col};
- $self->store_column($col => $inflated);
+ $self->store_column($col => $value);
}
else {
delete $self->{_column_data}{$col};
- $self->{_inflated_column}{$col} = $inflated;
+ $self->{_inflated_column}{$col} = $value;
}
- return $inflated;
+ return $value;
}
=head1 SEE ALSO