File Coverage

blib/lib/MooseX/Types/Wrapper.pm
Criterion Covered Total %
statement 21 21 100.0
branch 4 6 66.6
condition n/a
subroutine 5 5 100.0
pod n/a
total 30 32 93.7


line stmt bran cond sub pod time code
1             package MooseX::Types::Wrapper;
2             # ABSTRACT: Wrap exports from a library
3              
4             our $VERSION = '0.51';
5              
6 1     1   574315 use Carp::Clan qw( ^MooseX::Types );
  1         1637  
  1         5  
7 1     1   77 use Module::Runtime 'use_module';
  1         1  
  1         6  
8              
9 1     1   407 use namespace::autoclean;
  1         6766  
  1         3  
10              
11 1     1   49 use parent 'MooseX::Types';
  1         3  
  1         5  
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             sub import {
24 1     1   1967 my ($class, @args) = @_;
25 1 50       5 my %libraries = @args == 1 ? (Moose => $args[0]) : @args;
26              
27 1         2 for my $l (keys %libraries) {
28              
29             croak qq($class expects an array reference as import spec)
30 2 50       484 unless ref $libraries{ $l } eq 'ARRAY';
31              
32 2 100       6 my $library_class
33             = ($l eq 'Moose' ? 'MooseX::Types::Moose' : $l );
34 2         10 use_module($library_class);
35              
36             $library_class->import({
37             -into => scalar(caller),
38             -wrapper => $class,
39 2         1620 }, @{ $libraries{ $l } });
  2         15  
40             }
41 1         3948 return 1;
42             }
43              
44             1;
45              
46             __END__
47              
48             =pod
49              
50             =encoding UTF-8
51              
52             =head1 NAME
53              
54             MooseX::Types::Wrapper - Wrap exports from a library
55              
56             =head1 VERSION
57              
58             version 0.51
59              
60             =head1 DESCRIPTION
61              
62             See L<MooseX::Types/SYNOPSIS> for detailed usage.
63              
64             =head1 METHODS
65              
66             =head2 import
67              
68             =head1 SEE ALSO
69              
70             L<MooseX::Types>
71              
72             =head1 SUPPORT
73              
74             Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types>
75             (or L<bug-MooseX-Types@rt.cpan.org|mailto:bug-MooseX-Types@rt.cpan.org>).
76              
77             There is also a mailing list available for users of this distribution, at
78             L<http://lists.perl.org/list/moose.html>.
79              
80             There is also an irc channel available for users of this distribution, at
81             L<C<#moose> on C<irc.perl.org>|irc://irc.perl.org/#moose>.
82              
83             =head1 AUTHOR
84              
85             Robert "phaylon" Sedlacek <rs@474.at>
86              
87             =head1 COPYRIGHT AND LICENCE
88              
89             This software is copyright (c) 2007 by Robert "phaylon" Sedlacek.
90              
91             This is free software; you can redistribute it and/or modify it under
92             the same terms as the Perl 5 programming language system itself.
93              
94             =cut