Subject: | DBIx::Class::InflateColumn documentation: second arg in inflate/deflate subs exists but not covered by pod |
Date: | Fri, 13 Apr 2012 11:03:59 +0400 |
To: | bug-DBIx-Class [...] rt.cpan.org |
From: | Nikolay Shaplov <n [...] shaplov.ru> |
I was writing a schema that should use different inflate/deflate functions for
"content" attribute, depending on the value of "type" attr.
First I read a documentation and thought it is impossible.
Then I've dumped all function arguments and found out that inflate/deflate subs
are receiving a Result Record as as a second argument. But this behavior is
not covered by documentation.
Using the Result Record arg you can do something like this:
__PACKAGE__->inflate_column('content' => {
deflate => sub {my $content = shift;
my $rr = shift;
return lc($content) if $rr->type eq 'NS';
.......
return $content;
},
});
If this behavior is not going to be changed in further versions (I hope it
will not) it is better to be property documented