X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FTypes%2FBase.pm;h=398ad9cde7c7ab9c5ea0a5403054e6c6bf1750ad;hb=6a1db9c7c89f006f6231aa64a9629dd1de7c5a15;hp=15ba3e492af1929a868d55dd60340a9aa4e09f68;hpb=16ddefbf6d5e6918471483ebaad42b52fd560cea;p=gitmo%2FMooseX-Types.git diff --git a/lib/MooseX/Types/Base.pm b/lib/MooseX/Types/Base.pm index 15ba3e4..398ad9c 100644 --- a/lib/MooseX/Types/Base.pm +++ b/lib/MooseX/Types/Base.pm @@ -1,4 +1,5 @@ package MooseX::Types::Base; +our $VERSION = "0.26"; use Moose; =head1 NAME @@ -7,7 +8,6 @@ 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 ); @@ -67,7 +67,10 @@ sub import { # the type itself push @{ $ex_spec{exports} }, $type_short, - sub { $wrapper->type_export_generator($type_short, $type_full) }; + sub { + bless $wrapper->type_export_generator($type_short, $type_full), + 'MooseX::Types::EXPORTED_TYPE_CONSTRAINT'; + }; # the check helper push @{ $ex_spec{exports} }, @@ -186,14 +189,97 @@ sub type_storage { } } +=head2 registered_class_types + +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}; +} + +=head2 registered_role_types + +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 AUTHOR AND COPYRIGHT +=head1 AUTHOR -Robert 'phaylon' Sedlacek Crs@474.atE>, with many thanks to -the C<#moose> cabal on C. +See L. =head1 LICENSE