3 MooseX::Types::Combine - Combine type libraries for exporting
7 package MooseX::Types::Combine;
16 package CombinedTypeLib;
18 use base 'MooseX::Types::Combine';
20 __PACKAGE__->provide_types_from(qw/TypeLib1 TypeLib2/);
24 use CombinedTypeLib qw/Type1 Type2 ... /;
28 Allows you to export types from multiple type libraries.
30 Libraries on the right side of the type libs passed to L</provide_types_from>
31 take precedence over those on the left in case of conflicts.
36 my ($class, @types) = @_;
39 my @type_libs = $class->provide_types_from;
40 Class::MOP::load_class($_) for @type_libs;
44 map +($_ => $lib), $lib->type_names
48 for my $type (@types) {
50 "$caller asked for a type ($type) which is not found in any of the"
51 . " type libraries (@type_libs) combined by $class\n"
54 push @{ $from{ $types{$type} } }, $type;
57 $_->import({ -into => $caller }, @{ $from{ $_ } })
63 =head2 provide_types_from
65 Sets or returns a list of type libraries to re-export from.
69 sub provide_types_from {
70 my ($class, @libs) = @_;
73 do { no strict 'refs'; \@{ "${class}::__MOOSEX_TYPELIBRARY_LIBRARIES" } };
75 @$store = @libs if @libs;
86 See L<MooseX::Types/AUTHOR>.
90 This program is free software; you can redistribute it and/or modify
91 it under the same terms as perl itself.