Querylet::Input - generic input handler for Querlet::Query


Querylet documentation Contained in the Querylet distribution.

Index


Code Index:

NAME

Top

Querylet::Input - generic input handler for Querlet::Query

VERSION

Top

version 0.324

SYNOPSIS

Top

This is an abstract base class, meant for subclassing.

 package Querylet::Input::Term;
 use base qw(Querylet::Input);

 sub default_type { 'term' }
 sub handler      { \&from_term }  

 sub from_term {
   my ($query, $parameter) = @_;

   print "$parameter: ";
   my $input = <STDIN>;
   chomp $input;
   $query->{input}->{$parameter} = $input;
 }

 1;

Then, in a querylet:

 use Querylet::Input::Term

 query: SELECT * FROM users WHERE userid = ?

 input: userid

Or, to override the registered type:

 use Querylet::Input::Term 'stdin';

 output format: stdin

DESCRIPTION

Top

This class provides a simple way to write input handlers for Querylet, mostly by providing an import routine that will register the handler with the type-name requested by the using script.

The methods default_type and handler must exist, as described below.

IMPORT

Top

Querylet::Input provides an import method that will register the handler when the module is imported. If an argument is given, it will be used as the type name to register. Otherwise, the result of default_type is used.

METHODS

Top

default_type

This method returns the name of the type for which the input handler will be registered if no override is given.

handler

This method returns a reference to the handler, which will be used to register the handler.

AUTHOR

Top

Ricardo SIGNES, <rjbs@cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-querylet@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT

Top


Querylet documentation Contained in the Querylet distribution.
package Querylet::Input;

use strict;
use warnings;

use Carp;

our $VERSION = '0.324';

sub import {
	my ($class, $type) = @_;
	$type = $class->default_type unless $type;

	my $handler = $class->handler;

	Querylet::Query->register_input_handler($type => $handler);
}

sub default_type { croak "default_type method unimplemented" }

sub handler { croak "handler method unimplemented" }

"I do endeavor to give satisfaction, sir.";