NAME
MOP4Import::Pairs - pragma dispatcher for name => [@pragma]... style protocol
SYNOPSIS
package
YourExporter;
sub
import
{
my
$myPack
=
shift
;
my
Opts
$opts
= m4i_opts([
caller
]);
# Invoke declare_foobar for each $name => $pragmas pairs.
$myPack
->dispatch_pairs_as_declare(
foobar
=>
$opts
,
@_
);
}
sub
declare_foobar {
(
my
$myPack
,
my
Opts
$opts
,
my
(
$name
,
@pragmas
)) = m4i_args(
@_
);
...
}
#-----------------------------------
# Then you can use above module in other script like following
#-----------------------------------
use
YourExporter (
xxx
=> [1..3],
yyy
=> [4..6]
);
# Above is equivalent of following:
BEGIN {
YourExporter->declare_foobar(__PACKAGE__, xxx, 1..3);
YourExporter->declare_foobar(__PACKAGE__, yyy, 4..6);
}
DESCRIPTION
This module provides name => [@pragma_list]
style dispatcher of MOP4Import::Declare pragmas. Mainly used from MOP4Import::Types.
"MetaObject Protocol for Import" in this module
This module does not provide "import" itself. Instead, this provides a helper method dispatch_pairs_as_declare
to implement "import".
METHODS
dispatch_pairs_as_declare($pragma, $opts, @name_pragmalist_pairs)
This basically does following:
sub
dispatch_pairs_as_declare {
(
my
$myPack
,
my
$pragma
,
my
Opts
$opts
,
my
(
@pairs
)) =
@_
;
my
$method
=
"declare_$pragma"
;
while
(
my
(
$typename
,
$pragma_list
) =
splice
@pairs
, 0, 2) {
$myPack
->
$method
(
$opts
,
$typename
,
@$pragma_list
);
}
}
AUTHOR
Kobayashi, Hiroaki <hkoba@cpan.org>
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.