DeclareX/Plugin/imports.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 43 CC 3 SCAR 16.7
CC
3
Cov
0%
plugin_setup
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 5.3
1 package MooseX::DeclareX::Plugin::imports;
2  
3 BEGIN {
4 $MooseX::DeclareX::Plugin::imports::AUTHORITY = 'cpan:TOBYINK';
5 $MooseX::DeclareX::Plugin::imports::VERSION = '0.009';
6 }
7  
8 use Moose;
9 with 'MooseX::DeclareX::Plugin';
10  
11 use MooseX::Declare ();
12 use Moose::Util ();
13 use Data::OptList;
14 use Data::Dumper;
15  
16 sub plugin_setup
17 {
18 my ($class, $kw, $opt) = @_;
19 $opt = Data::OptList::mkopt($opt);
20
21 local $Data::Dumper::Terse = 1;
22 local $Data::Dumper::Indent = 0;
23 my @codeparts = map {
24 my ($module, $terms) = @$_;
25 $terms = [] unless defined $terms;
26 confess "parameters for $module must be an arrayref"
27 unless ref $terms eq 'ARRAY';
28 sprintf('use %s @{%s}', $module, Dumper $terms);
29 } @$opt;
30  
31 $kw->meta->add_after_method_modifier(
32 add_namespace_customizations => sub {
33 my ($self, $ctx, $package) = @_;
34 $ctx->add_preamble_code_parts(@codeparts);
35 },
36 );
37 }
38  
39 1;
40