Acme-Sub-Parms
view release on metacpan or search on metacpan
Handle additional parameter styles
Fix source line numbering
lib/Acme/Sub/Parms.pm view on Meta::CPAN
#
# It takes two parameters:
#
# $raw_spec - this is the content of the [....] block (not including the '[' and ']' block delimitters)
# $field_name - the hash key for the field being processed
#
# As each line of the BindParms block is processed the two parameters for each line are passed to the bind_spec
# method for evaluation. bind_spec should return a string containing any Perl code generated as a result of
# the bind specification.
#
# Good style dictates that the returned output should be *ONE* line (it could be a very *long* line)
# so that line numbering in the source file is preserved for any error messages.
#
sub bind_spec {
my $self = shift;
my ($raw_spec, $field_name) = @_;
my $options = $self->{'options'};
my $no_validation = $options->{_NO_VALIDATION()};
my $spec_tokens = $self->_parse_bind_spec($raw_spec);
lib/Acme/Sub/Parms.pod view on Meta::CPAN
my $defaulted : dthing [optional, default="help me"];
)
#...
}
=head1 DESCRIPTION
Acme::Sub::Parms uses a source filter to rewrite the code during the
module load with efficient inline parameter processing code that
handles some common cases for simple Perl style named parameter key/value
parameter lists. It can handle either case-sensitive or case-insensitive
parameters as desired.
In essence, it provides some syntactic sugar for parameter declaration
and validation.
Typical usage is follows:
sub a_function {
BindParms : (
lib/Acme/Sub/Parms.pod view on Meta::CPAN
=back
=over 4
=item callback=function_name
The 'callback' declaration lets you specify a function name to be used
to perform validation on the parameter(s).
The syntax is simple: callback=validation_function_name
There is no support for method style calls, only ordinary function calls.
The callback function is called with three
parameters: ($field_name, $field_value, $arguments_anon_hash)
The $field_name and $field_value arguments are obvious,
the $arguments_anon_hash is a 'live' reference to a hash containing
all of the arguments being processed by BindParms block.
Because it is a 'live' hash reference, alterations to the hash will be
reflected in subsequent binding lines and in the final values bound.
( run in 1.116 second using v1.01-cache-2.11-cpan-49f99fa48dc )