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