[SearchBuilder-devel] [RFC] JDBI::Filters should be configurable
via column info
Ruslan Zakirov
ruslan.zakirov at gmail.com
Wed Sep 21 16:06:45 EDT 2005
On 9/20/05, Jesse Vincent <jesse at bestpractical.com> wrote:
> On Tue, Sep 20, 2005 at 08:36:54PM +0400, Ruslan Zakirov wrote:
> > Hello.
> > subj, for example Filter::Encoding that will allow programmer to
> > choose encoding he want be used for stored value or set DateTime field
> > by default to current time.
> >
> > It should be well defined where and how programmers of the filters
> > should get this arguments.
>
>
> Yes. That was very much my intent. I just wasn't there yet. Arguably
> there should be ways to do:
>
> * global filters
I don't see much usage of it.
> * app-specific filters
IMHO this is not special group of filters, but app can override
methods which return filters lists and add/remove filters. As Robert
said: - "they can always write a custom accessor/modifier/whateverer
to munge the data"
> * column specific filters
Looks like current code implement this type of filters, but really it
implements something like global filters.
> * column type specific filters.
Where do you want to describe this?
> * database specific filters
DB type(Oracle, Pg...) specific?
API design:
I think almost all this can be done with two methods, but defined for
different classes: Handle, Record, Column.
public API:
I suggest two methods: input_filters, output_filters.
In JDBI core this methods looks like:
sub input_filters { return @our_default_list }
sub output_filters { return reverse $_[0]->input_filters }
So if someone wants different chain for output then he override
output_filters method.
private API methods:
sub Record::_filters( $direction, $column ) {
my @filters = ();
my @objs = ($self, $column, $self->handle);
@objs = reverse @objs if $direction eq 'output';
my $method = $direction ."_filters";
foreach my $obj( @objs ) {
push @filters, $obj->$method( column => $column, record => $self );
}
return @filters;
}
sub Record::_apply_input_filters( $column, $value_ref );
sub Record::_apply_output_filters( $column, $value_ref );
sub Record::__apply_filters( $action, $column, $value_ref, @list );
Thoughts?
>
>
> > --
> > Best regards, Ruslan.
> > _______________________________________________
> > SearchBuilder-devel mailing list
> > SearchBuilder-devel at bestpractical.com
> > http://lists.bestpractical.com/cgi-bin/mailman/listinfo/searchbuilder-devel
> >
>
> --
>
--
Best regards, Ruslan.
More information about the SearchBuilder-devel
mailing list