| 1 | package MooseX::Types::Wrapper; | ||||||||||
| 2 | # ABSTRACT: Wrap exports from a library | ||||||||||
| 3 | |||||||||||
| 4 | 1 | our $VERSION = '0.51'; | |||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Carp::Clan qw( ^MooseX::Types ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Module::Runtime 'use_module'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | use parent 'MooseX::Types'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | #pod =head1 DESCRIPTION | ||||||||||
| 14 | #pod | ||||||||||
| 15 | #pod See L<MooseX::Types/SYNOPSIS> for detailed usage. | ||||||||||
| 16 | #pod | ||||||||||
| 17 | #pod =head1 METHODS | ||||||||||
| 18 | #pod | ||||||||||
| 19 | #pod =head2 import | ||||||||||
| 20 | #pod | ||||||||||
| 21 | #pod =cut | ||||||||||
| 22 | |||||||||||
| 23 | 1 | ▶ | sub import { | ||||||||
|
Subroutine
import: called CC=5 SCAR=16.2
| |||||||||||
| 24 | 1 | my ($class, @args) = @_; | |||||||||
| 25 | 1 | ▶ | my %libraries = @args == 1 ? (Moose => $args[0]) : @args; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | |||||||||||
| 27 | 1 | for my $l (keys %libraries) { | |||||||||
| 28 | |||||||||||
| 29 | croak qq($class expects an array reference as import spec) | ||||||||||
| 30 | 2 | ▶ | unless ref $libraries{ $l } eq 'ARRAY'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | |||||||||||
| 32 | 2 | ▶ | my $library_class | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | = ($l eq 'Moose' ? 'MooseX::Types::Moose' : $l ); | ||||||||||
| 34 | 2 | use_module($library_class); | |||||||||
| 35 | |||||||||||
| 36 | $library_class->import({ | ||||||||||
| 37 | -into => scalar(caller), | ||||||||||
| 38 | -wrapper => $class, | ||||||||||
| 39 | 2 | }, @{ $libraries{ $l } }); | |||||||||
| 40 | } | ||||||||||
| 41 | 1 | return 1; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 1 | 1; | |||||||||
| 45 | |||||||||||
| 46 | __END__ | ||||||||||