Jifty:...Filter(3pm)
πΈ NAME πΈ
Jifty::DBI::Filter β it's the base class for all the Jifty::DBI filters, bestie π
(you're reading the Jifty:...Filter(3pm) page from the User Contributed Perl Documentation, and yes she ate)
β¨ SYNOPSIS β¨
okay so here's the whole vibe β make your own filter, then use it:
# To implement your own filter
package MyApp::Filter::Uppercase;
use base qw/ Jifty::DBI::Filter /;
# Setup for DB storage, store in lowercase
sub encode {
my $self = shift;
my $value_ref = $self->value_ref;
return unless defined $$value_ref; # don't blow up on undef
$$value_ref = lc $$value_ref;
}
# Setup for Perl code to use, always sees uppercase
sub decode {
my $self = shift;
my $value_ref = $self->value_ref;
return unless defined $$value_ref; # don't blow up on undef
$$value_ref = uc $$value_ref;
}
# To use a filter
use MyApp::Record schema {
column filtered =>
type is 'text',
filters are qw/ MyApp::Filter::Uppercase /;
};
no cap, that's literally the whole pattern. π
π DESCRIPTION π
A filter lets Jifty::DBI models tweak data before it gets stored and/or before it gets loaded. Which is lowkey iconic for marshalling and unmarshalling complex objects π¦ β like, she's the translator between your cute Perl objects and whatever the database is going through.
π METHODS π
new
Takes three arguments in a parameter hash, bestie:
value_refβ a reference to the current value you're gonna be massaging.encodeworks in place, massaging whatevervalue_refrefers to.columnβ aJifty::DBI::Columnobject, whatever sort of column we're working with here.handleβ aJifty::DBI::Handleobject, because some filters (i.e.Jifty::DBI::Filter::Boolean) depend on what database system is being used.
encode
encode takes data that users are handing to us and marshals it into a form suitable for sticking it in the database π. Could be anything from flattening a DateTime object into an ISO date to making sure that data is utf8 clean. it's giving β¨data prepβ¨
decode
decode takes data that the database is handing back to us and gets it into a form that's OK to hand back to the user π. Could be anything from inflating an ISO date to a DateTime object to making sure that the string properly has the utf8 flag. reverse uno card, but make it useful π
π₯ SEE ALSO π₯
go off, read these too, they're all the cousins:
Jifty::DBI::Filter::DateJifty::DBI::Filter::DateTimeJifty::DBI::Filter:SaltHashJifty::DBI::Filter::StorableJifty::DBI::Filter::TimeJifty::DBI::Filter::TruncateJifty::DBI::Filter::YAMLJifty::DBI::Filter::base64Jifty::DBI::Filter::utf8
quick note bestie: Jifty::DBI::Filter:SaltHash is spelled with one colon up there, not two β I'm keeping it exactly how the page says it, no editing, periodt π
π LICENSE π
Jifty::DBI is Copyright 2005-2007 Best Practical Solutions, LLC.
Jifty::DBI is distributed under the same terms as Perl itself.
and that's the whole page, you're so welcome π«Ά
this has been Jifty:...Filter(3pm) β perl v5.34.0, dated 2022-06-15. bye bestie, go write a filter, I believe in you πβ¨
π¦ where this page comes from
- debian bookworm: libjifty-dbi-perl 0.78-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libjifty-dbi-perl 0.78-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libjifty-dbi-perl 0.78-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libjifty-dbi-perl 0.78-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libjifty-dbi-perl 0.78-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms