File Coverage

blib/lib/MooX/BuildClass/Utils.pm
Criterion Covered Total %
statement 20 20 100.0
branch 4 4 100.0
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 31 31 100.0


line stmt bran cond sub pod time code
1             package MooX::BuildClass::Utils;
2              
3 4     4   21 use strictures 2;
  4         25  
  4         1371  
4              
5 4     4   798 use Module::Runtime 'module_notional_filename';
  4         7  
  4         26  
6              
7 4     4   5040 use parent 'Exporter';
  4         1247  
  4         21  
8              
9             our @EXPORT_OK = qw( make_variant_package_name make_variant );
10              
11             our $VERSION = '0.152700'; # VERSION
12              
13             # ABSTRACT: methods for MooX::BuildClass and MooX::BuildRole
14              
15             #
16             # This file is part of Throwable-SugarFactory
17             #
18             #
19             # Christian Walde has dedicated the work to the Commons by waiving all of his
20             # or her rights to the work worldwide under copyright law and all related or
21             # neighboring legal rights he or she had in the work, to the extent allowable by
22             # law.
23             #
24             # Works under CC0 do not require attribution. When citing the work, you should
25             # not imply endorsement by the author.
26             #
27              
28              
29             sub make_variant_package_name {
30 28     28 1 12894 my ( undef, $name ) = @_;
31              
32 28         89 my $path = module_notional_filename $name;
33 28 100       581 die "Won't clobber already loaded: $path => $INC{$path}" if $INC{$path};
34              
35 26         96 return $name;
36             }
37              
38              
39             sub make_variant {
40 26     26 1 17684 my ( $class, undef, undef, @args ) = @_;
41 26         81 while ( @args ) {
42 51         32483 my ( $func, $args ) = ( shift @args, shift @args );
43 51 100       156 $args = [$args] if ref $args ne "ARRAY";
44 51         69 $class->can( $func )->( @{$args} );
  51         309  
45             }
46 26         48923 return;
47             }
48              
49             1;
50              
51             __END__