Acme-Sub-Parms

 view release on metacpan or  search on metacpan

Build.PL  view on Meta::CPAN


use Module::Build;
my $build = Module::Build->new
      ( module_name    => 'Acme::Sub::Parms',
        dist_author    => 'Jerilyn Franz <cpan@jerilyn.info>',
        dist_abstract  => 'Function/Method parameter processing handlers',
        license        => 'mit',
        requires       => {
            'perl'              => '5.006',
            'warnings'          => 0,
            'Carp'              => 0,
            'Filter::Util::Call' => '1.06',
            },
        build_requires => { },
        test_requires       => {
            'perl'              => '5.006',

META.json  view on Meta::CPAN

{
   "abstract" : "Function/Method parameter processing handlers",
   "author" : [
      "Jerilyn Franz <cpan@jerilyn.info>"
   ],
   "dynamic_config" : 1,
   "generated_by" : "Module::Build version 0.4224",
   "license" : [
      "mit"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

META.yml  view on Meta::CPAN

---
abstract: 'Function/Method parameter processing handlers'
author:
  - 'Jerilyn Franz <cpan@jerilyn.info>'
build_requires:
  Carp: '0'
  Filter::Util::Call: '1.06'
  perl: '5.006'
  warnings: '0'
configure_requires:
  Module::Build: '0.42'
dynamic_config: 1

README  view on Meta::CPAN

Acme::Sub::Parms

Provides simple function/method parameter processing handlers 

To install:

perl Makefile.PL
make
make test
make install

Alternatively, if you have Module::Build installed,

lib/Acme/Sub/Parms.pm  view on Meta::CPAN

    return $spec_tokens;
}

###############################################################################
# bind_spec is intentionally a a non-POD documented'public' method. It can be overridden in a sub-class
# to provide alternative features.
# 
# 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) = @_;

lib/Acme/Sub/Parms.pod  view on Meta::CPAN

         my $yathing        : yathing [optional, is_defined];
         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 {

lib/Acme/Sub/Parms.pod  view on Meta::CPAN


=over 4

=item :no_validation

This flags that bound parameters should B<NOT> be validated according
to any validation specifications.

If this flag is used, then parameters will be bound, callbacks and
defaults applied, but validation checking will be disabled. This
provides a significant performance boost to parameter processing
in mature code that doesn't need runtime parameter assertion checking.

=item :normalize

This flags that bound parameters should ignore the difference between
upper and lowercase names for parameters. This permits the caller to
use MixedCase, UPPERCASE, or lowercase parameters names interchangeably
(with a noticable performance penalty).

=item :dump_to_stdout

lib/Acme/Sub/Parms.pod  view on Meta::CPAN

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.
This is a powerful, but simultaneously very dangerous feature. Use
this ability with caution. 

The callback must return either a true or a false value (not the
literal words 'true' or 'false' but something that evaluates to
a true or false logical value) and a string with an error message
(if a false value was returned.)



( run in 0.414 second using v1.01-cache-2.11-cpan-8d75d55dd25 )