Jifty::DBI::Filter(3pm)

Jifty::DBI::Filter3pm

Base class for jifty::dbi filters

Usage

  # 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 /;
  };

Overview

A filter allows Jifty::DBI models to tweak data prior to being stored and/or loaded. This is useful for marshalling and unmarshalling complex objects.

Methods

new

Takes three arguments in a parameter hash:

value_ref

A reference to the current value you're going to be massaging. "encode" works in place, massaging whatever value_ref refers to.

column

A Jifty::DBI::Column object, whatever sort of column we're working with here.

handle

A Jifty::DBI::Handle object, 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. This could be anything from flattening a DateTime object into an ISO date to making sure that data is utf8 clean.

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. This could be anything from inflating an ISO date to a DateTime object to making sure that the string properly has the utf8 flag.

Releases

9 releases since Debian 5.0 (Lenny); the text changed 5 times.

  1. 5.0
  2. 6.0
  3. 7
  4. 8
  5. 9–11
  6. 12–13

License

Jifty::DBI is Copyright 2005-2007 Best Practical Solutions, LLC. Jifty::DBI is distributed under the same terms as Perl itself.

From libjifty-dbi-perl 0.78-3 in Debian 13 (Trixie). Parsed by carta from the page's man source.