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   18 use strictures 2;
  4         21  
  4         1295  
4              
5 4     4   802 use Module::Runtime 'module_notional_filename';
  4         7  
  4         1112  
6              
7 4     4   3784 use parent 'Exporter';
  4         1046  
  4         17  
8              
9             our @EXPORT_OK = qw( make_variant_package_name make_variant );
10              
11             our $VERSION = '0.152690'; # 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 13834 my ( undef, $name ) = @_;
31              
32 28         98 my $path = module_notional_filename $name;
33 28 100       595 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 16430 my ( $class, undef, undef, @args ) = @_;
41 26         76 while ( @args ) {
42 51         27442 my ( $func, $args ) = ( shift @args, shift @args );
43 51 100       170 $args = [$args] if ref $args ne "ARRAY";
44 51         67 $class->can( $func )->( @{$args} );
  51         284  
45             }
46 26         56871 return;
47             }
48              
49             1;
50              
51             __END__