switching over to dzil
[gitmo/MooseX-Types.git] / lib / MooseX / Types / Base.pm
index 3b2b40e..e172d19 100644 (file)
@@ -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<MooseX::Types::Moose>
+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<class_type> 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<class_type> 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 C<E<lt>rs@474.atE<gt>>, with many thanks to
-the C<#moose> cabal on C<irc.perl.org>.
+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<role_type> 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<role_type> 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<MooseX::Types::Moose>
 
 =head1 LICENSE