3 MooseX::Types::Combine - Combine type libraries for exporting
7 package MooseX::Types::Combine;
15 package CombinedTypeLib;
17 use base 'MooseX::Types::Combine';
19 __PACKAGE__->provide_types_from(qw/TypeLib1 TypeLib2/);
23 use CombinedTypeLib qw/Type1 Type2 ... /;
27 Allows you to export types from multiple type libraries.
29 Libraries on the right side of the type libs passed to L</provide_types_from>
30 take precedence over those on the left in case of conflicts.
35 my ($class, @types) = @_;
38 my @type_libs = $class->provide_types_from;
39 Class::MOP::load_class($_) for @type_libs;
43 map +($_ => $lib), $lib->type_names
47 push @{ $from{ $types{ $_ } } }, $_ for @types;
49 $_->import({ -into => $caller }, @{ $from{ $_ } })
55 =head2 provide_types_from
57 Sets or returns a list of type libraries to re-export from.
61 sub provide_types_from {
62 my ($class, @libs) = @_;
65 do { no strict 'refs'; \@{ "${class}::__MOOSEX_TYPELIBRARY_LIBRARIES" } };
67 @$store = @libs if @libs;
78 See L<MooseX::Types/AUTHOR>.
82 This program is free software; you can redistribute it and/or modify
83 it under the same terms as perl itself.