On 24 Oct 2008, at 13:32, jackal wrote:
On Thursday 23 October 2008 20:18:49 Jess Robinson wrote:
On Tue, 21 Oct 2008, jackal wrote:
This is proposal for a filtering component, similar to
DBIx::Class::InflateColumn
It can -modify- columns transparently. When you read column - it
inflates, when you write - deflates.
On creating a new column, whole cycle passed - deflating for DB and
inflating for usage.
Module can handle scalars, because of it's destination - to modify
data.
I think I see where you are going, but can you give some actual
examples
with data, how to use it etc?
Someone did start/implement a ::Filter module, but I'm not sure
where that
went or why it disappeared.. That one was *just* for scalar to scalar
though.
One example is in a module documentation:
package DB::Test;
use String::Util ':all';
__PACKAGE__->modify_column('html', {
inflate => sub { htmlesc(shift) }, # escaping html entities
deflate => sub { crunch(shift); } # removing extra whitespaces
});
in a script:
$r = $schema->resultset('Test')->create({html => ' a & b '}); # it
will be
deflated into DB as 'a & b'
$r->html; # inflated as 'a & b'
$r->html(' c & d '); # deflated into DB as 'c & d'
$r->update;
$r->html; # inflated as 'c & b'
Ignoring the usefuless or not of this module: HTML escaping belongs in
template.
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]