X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FTypeConstraint%2FRegistry.pm;h=0625b36d5ce5ce7a32f74ef994b7a62afa5e9e60;hb=f4cbcca146f48c91c74ae618f71895376fd338a4;hp=85ccf6fe5b22b3fe3997ac0db3cf24e111e0569b;hpb=07b0f1a5599bf1a0ed99933200ca27290e9a468a;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/TypeConstraint/Registry.pm b/lib/Moose/Meta/TypeConstraint/Registry.pm index 85ccf6f..0625b36 100644 --- a/lib/Moose/Meta/TypeConstraint/Registry.pm +++ b/lib/Moose/Meta/TypeConstraint/Registry.pm @@ -8,7 +8,8 @@ use metaclass; use Scalar::Util 'blessed'; use Carp 'confess'; -our $VERSION = '0.51'; +our $VERSION = '0.55_03'; +$VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; use base 'Class::MOP::Object'; @@ -26,7 +27,7 @@ __PACKAGE__->meta->add_attribute('type_constraints' => ( sub new { my $class = shift; - my $self = $class->meta->new_object(@_); + my $self = $class->_new(@_); return $self; } @@ -37,11 +38,14 @@ sub has_type_constraint { sub get_type_constraint { my ($self, $type_name) = @_; + return unless defined $type_name; $self->type_constraints->{$type_name} } sub add_type_constraint { my ($self, $type) = @_; + confess("No type supplied / type is not a valid type constraint") + unless ($type && blessed $type && $type->isa('Moose::Meta::TypeConstraint')); $self->type_constraints->{$type->name} = $type; } @@ -93,8 +97,15 @@ base Moose registry and base Moose types will automagically be found too). =item B +Returns a type constraint object from the registry by name. Will return +false if the supplied type name cannot be found. + =item B +Adds a type constraint object to the registry. Will throw an exception if +no type is supplied, or the supplied object does not inherit from +L + =item B =back