X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FTypes%2FBase.pm;h=e172d19eb9f5e447a6b97b548e2a80a2239790a3;hb=ef8b7b7a254653b0e77d19b19d7bd870700cf4b2;hp=3b2b40e78456b5f12a40771a3e71e4e9ecc1beb6;hpb=5885c4f4e1f234e7521f952bd1c1956395494c1e;p=gitmo%2FMooseX-Types.git diff --git a/lib/MooseX/Types/Base.pm b/lib/MooseX/Types/Base.pm index 3b2b40e..e172d19 100644 --- a/lib/MooseX/Types/Base.pm +++ b/lib/MooseX/Types/Base.pm @@ -1,13 +1,8 @@ package MooseX::Types::Base; use Moose; -=head1 NAME +# ABSTRACT: Type library base class -MooseX::Types::Base - Type library base class - -=cut - -#use Data::Dump qw( dump ); use Carp::Clan qw( ^MooseX::Types ); use MooseX::Types::Util qw( filter_tags ); use Sub::Exporter qw( build_exporter ); @@ -189,14 +184,93 @@ sub type_storage { } } -=head1 SEE ALSO +=head2 registered_class_types -L +Returns the class types registered within this library. Don't use directly. + +=cut + +sub registered_class_types { + my ($class) = @_; + + { + no strict 'refs'; + return \%{ $class . '::__MOOSEX_TYPELIBRARY_CLASS_TYPES' }; + } +} + +=head2 register_class_type + +Register a C for use in this library by class name. + +=cut + +sub register_class_type { + my ($class, $type) = @_; + + croak "Not a class_type" + unless $type->isa('Moose::Meta::TypeConstraint::Class'); + + $class->registered_class_types->{$type->class} = $type; +} + +=head2 get_registered_class_type + +Get a C registered in this library by name. + +=cut + +sub get_registered_class_type { + my ($class, $name) = @_; + + $class->registered_class_types->{$name}; +} -=head1 AUTHOR AND COPYRIGHT +=head2 registered_role_types -Robert 'phaylon' Sedlacek Crs@474.atE>, with many thanks to -the C<#moose> cabal on C. +Returns the role types registered within this library. Don't use directly. + +=cut + +sub registered_role_types { + my ($class) = @_; + + { + no strict 'refs'; + return \%{ $class . '::__MOOSEX_TYPELIBRARY_ROLE_TYPES' }; + } +} + +=head2 register_role_type + +Register a C for use in this library by role name. + +=cut + +sub register_role_type { + my ($class, $type) = @_; + + croak "Not a role_type" + unless $type->isa('Moose::Meta::TypeConstraint::Role'); + + $class->registered_role_types->{$type->role} = $type; +} + +=head2 get_registered_role_type + +Get a C registered in this library by role name. + +=cut + +sub get_registered_role_type { + my ($class, $name) = @_; + + $class->registered_role_types->{$name}; +} + +=head1 SEE ALSO + +L =head1 LICENSE