From: Shawn M Moore Date: Mon, 22 Dec 2008 02:30:56 +0000 (+0000) Subject: Finish renaming Mouse::TypeRegistry to Mouse::Util::TypeConstraints X-Git-Tag: 0.19~98 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3b46bd4991dea7ead4e7f52a089222d24554e2bd;p=gitmo%2FMouse.git Finish renaming Mouse::TypeRegistry to Mouse::Util::TypeConstraints --- diff --git a/Changes b/Changes index d4ca835..1816af2 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,8 @@ Revision history for Mouse 0.15 * Don't export Mouse's sugar into the package 'main' + * Rename Mouse::TypeRegistry to Mouse::Util::TypeConstraints + 0.14 Sat Dec 20 16:53:05 2008 * POD fix diff --git a/lib/Mouse.pm b/lib/Mouse.pm index 97914a6..18c60d1 100644 --- a/lib/Mouse.pm +++ b/lib/Mouse.pm @@ -21,7 +21,7 @@ use Mouse::Util; use Mouse::Meta::Attribute; use Mouse::Meta::Class; use Mouse::Object; -use Mouse::TypeRegistry; +use Mouse::Util::TypeConstraints; our @EXPORT = qw(extends has before after around blessed confess with); diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index c4b5e01..887afc3 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -83,7 +83,7 @@ sub generate_accessor { if ($constraint) { $accessor .= 'my $val = '; if ($should_coerce) { - $accessor .= 'Mouse::TypeRegistry->typecast_constraints("'.$attribute->associated_class->name.'", $attribute->{find_type_constraint}, $attribute->{type_constraint}, '.$value.');'; + $accessor .= 'Mouse::Util::TypeConstraints->typecast_constraints("'.$attribute->associated_class->name.'", $attribute->{find_type_constraint}, $attribute->{type_constraint}, '.$value.');'; } else { $accessor .= $value.';'; } @@ -210,7 +210,7 @@ sub create { my @type_constraints = split /\|/, $type_constraint; my $code; - my $optimized_constraints = Mouse::TypeRegistry->optimized_constraints; + my $optimized_constraints = Mouse::Util::TypeConstraints->optimized_constraints; if (@type_constraints == 1) { $code = $optimized_constraints->{$type_constraints[0]} || sub { Scalar::Util::blessed($_) && $_->isa($type_constraints[0]) }; @@ -343,7 +343,7 @@ sub verify_type_constraint_error { sub coerce_constraint { ## my($self, $value) = @_; my $type = $_[0]->{type_constraint} or return $_[1]; - return Mouse::TypeRegistry->typecast_constraints($_[0]->associated_class->name, $_[0]->find_type_constraint, $type, $_[1]); + return Mouse::Util::TypeConstraints->typecast_constraints($_[0]->associated_class->name, $_[0]->find_type_constraint, $type, $_[1]); } sub _canonicalize_handles { diff --git a/lib/Mouse/Meta/Method/Constructor.pm b/lib/Mouse/Meta/Method/Constructor.pm index efdf353..5b8b5d2 100644 --- a/lib/Mouse/Meta/Method/Constructor.pm +++ b/lib/Mouse/Meta/Method/Constructor.pm @@ -42,7 +42,7 @@ sub _generate_processattrs { $code .= "if (exists \$args->{'$from'}) {\n"; if ($attr->should_coerce && $attr->type_constraint) { - $code .= "my \$value = Mouse::TypeRegistry->typecast_constraints('".$attr->associated_class->name."', \$attrs[$index]->{find_type_constraint}, \$attrs[$index]->{type_constraint}, \$args->{'$from'});\n"; + $code .= "my \$value = Mouse::Util::TypeConstraints->typecast_constraints('".$attr->associated_class->name."', \$attrs[$index]->{find_type_constraint}, \$attrs[$index]->{type_constraint}, \$args->{'$from'});\n"; } else { $code .= "my \$value = \$args->{'$from'};\n"; @@ -78,7 +78,7 @@ sub _generate_processattrs { $code .= "my \$value = "; if ($attr->should_coerce && $attr->type_constraint) { - $code .= "Mouse::TypeRegistry->typecast_constraints('".$attr->associated_class->name."', \$attrs[$index]->{find_type_constraint}, \$attrs[$index]->{type_constraint}, "; + $code .= "Mouse::Util::TypeConstraints->typecast_constraints('".$attr->associated_class->name."', \$attrs[$index]->{find_type_constraint}, \$attrs[$index]->{type_constraint}, "; } if ($attr->has_builder) { diff --git a/lib/Mouse/Util/TypeConstraints.pm b/lib/Mouse/Util/TypeConstraints.pm index a10e7a4..812ecd6 100644 --- a/lib/Mouse/Util/TypeConstraints.pm +++ b/lib/Mouse/Util/TypeConstraints.pm @@ -1,4 +1,4 @@ -package Mouse::TypeRegistry; +package Mouse::Util::TypeConstraints; use strict; use warnings; @@ -166,7 +166,7 @@ __END__ =head1 NAME -Mouse::TypeRegistry - simple type constraints +Mouse::Util::TypeConstraints - simple type constraints =head1 METHODS diff --git a/lib/MouseX/Types.pm b/lib/MouseX/Types.pm index 713984c..68003a8 100644 --- a/lib/MouseX/Types.pm +++ b/lib/MouseX/Types.pm @@ -2,7 +2,7 @@ package MouseX::Types; use strict; use warnings; -require Mouse::TypeRegistry; +require Mouse::Util::TypeConstraints; use MouseX::Types::TypeDecorator; sub import { @@ -22,7 +22,7 @@ sub import { } } - return Mouse::TypeRegistry->import( callee => $caller ); + return Mouse::Util::TypeConstraints->import( callee => $caller ); } sub _import { diff --git a/lib/MouseX/Types/Mouse.pm b/lib/MouseX/Types/Mouse.pm index 65874a9..1d62675 100644 --- a/lib/MouseX/Types/Mouse.pm +++ b/lib/MouseX/Types/Mouse.pm @@ -2,11 +2,11 @@ package MouseX::Types::Mouse; use strict; use warnings; -BEGIN { require Mouse::TypeRegistry } +BEGIN { require Mouse::Util::TypeConstraints } use MouseX::Types; BEGIN { - my $builtin_type = +{ map { $_ => $_ } Mouse::TypeRegistry->list_all_builtin_type_constraints }; + my $builtin_type = +{ map { $_ => $_ } Mouse::Util::TypeConstraints->list_all_builtin_type_constraints }; sub type_storage { $builtin_type } } diff --git a/t/501_moose_coerce_mouse.t b/t/501_moose_coerce_mouse.t index 1d8cc19..486e118 100644 --- a/t/501_moose_coerce_mouse.t +++ b/t/501_moose_coerce_mouse.t @@ -20,7 +20,7 @@ use Test::Exception; { package Response; use Mouse; - use Mouse::TypeRegistry; + use Mouse::Util::TypeConstraints; subtype 'HeadersType' => where { defined $_ && eval { $_->isa('Headers') } }; coerce 'HeadersType' => diff --git a/t/800_shikabased/001-coerce.t b/t/800_shikabased/001-coerce.t index d20395d..5b19a5b 100644 --- a/t/800_shikabased/001-coerce.t +++ b/t/800_shikabased/001-coerce.t @@ -11,7 +11,7 @@ use Test::More tests => 6; { package Response; use Mouse; - use Mouse::TypeRegistry; + use Mouse::Util::TypeConstraints; subtype 'HeadersType' => as 'Object' => where { defined $_ && eval { $_->isa('Headers') } }; coerce 'HeadersType' => diff --git a/t/800_shikabased/002-coerce_multi_class.t b/t/800_shikabased/002-coerce_multi_class.t index 5b9775b..2bfd2d2 100644 --- a/t/800_shikabased/002-coerce_multi_class.t +++ b/t/800_shikabased/002-coerce_multi_class.t @@ -16,7 +16,7 @@ use Test::More tests => 14; { package Response; use Mouse; - use Mouse::TypeRegistry; + use Mouse::Util::TypeConstraints; subtype 'Headers' => where { defined $_ && eval { $_->isa('Response::Headers') } }; coerce 'Headers' => @@ -34,7 +34,7 @@ use Test::More tests => 14; eval { package Request; - use Mouse::TypeRegistry; + use Mouse::Util::TypeConstraints; subtype 'Headers' => where { defined $_ && eval { $_->isa('Request::Headers') } }; }; @@ -42,7 +42,7 @@ like $@, qr/The type constraint 'Headers' has already been created, cannot be cr eval { package Request; - use Mouse::TypeRegistry; + use Mouse::Util::TypeConstraints; coerce 'TooBad' => from 'HashRef' => via { @@ -54,7 +54,7 @@ like $@, qr/Cannot find type 'TooBad', perhaps you forgot to load it./; eval { package Request; - use Mouse::TypeRegistry; + use Mouse::Util::TypeConstraints; coerce 'Headers' => from 'HashRef' => via { @@ -66,7 +66,7 @@ like $@, qr/A coercion action already exists for 'HashRef'/; eval { package Request; - use Mouse::TypeRegistry; + use Mouse::Util::TypeConstraints; coerce 'Headers' => from 'HashRefa' => via { @@ -78,7 +78,7 @@ like $@, qr/Could not find the type constraint \(HashRefa\) to coerce from/; eval { package Request; - use Mouse::TypeRegistry; + use Mouse::Util::TypeConstraints; coerce 'Headers' => from 'ArrayRef' => via { diff --git a/t/800_shikabased/005-class_type.t b/t/800_shikabased/005-class_type.t index 18418e3..862b514 100644 --- a/t/800_shikabased/005-class_type.t +++ b/t/800_shikabased/005-class_type.t @@ -4,7 +4,7 @@ use Test::More tests => 4; { package Response; use Mouse; - use Mouse::TypeRegistry; + use Mouse::Util::TypeConstraints; class_type Headers => { class => 't::lib::ClassType_Foo' }; coerce 'Headers' => diff --git a/t/800_shikabased/006-role_type.t b/t/800_shikabased/006-role_type.t index fcbb55e..5893ddb 100644 --- a/t/800_shikabased/006-role_type.t +++ b/t/800_shikabased/006-role_type.t @@ -29,7 +29,7 @@ use Test::More tests => 5; { package Response; use Mouse; - use Mouse::TypeRegistry; + use Mouse::Util::TypeConstraints; role_type Headers => { role => 'Response::Headers::Role' }; coerce 'Headers' => diff --git a/t/800_shikabased/009-overwrite-builtin-subtype.t b/t/800_shikabased/009-overwrite-builtin-subtype.t index 9bdd60c..659a1a6 100644 --- a/t/800_shikabased/009-overwrite-builtin-subtype.t +++ b/t/800_shikabased/009-overwrite-builtin-subtype.t @@ -4,7 +4,7 @@ use Test::More tests => 1; eval { package Request; - use Mouse::TypeRegistry; + use Mouse::Util::TypeConstraints; subtype 'Int' => where { 1}; }; diff --git a/t/800_shikabased/010-isa-or.t b/t/800_shikabased/010-isa-or.t index 8708ae3..8b45921 100644 --- a/t/800_shikabased/010-isa-or.t +++ b/t/800_shikabased/010-isa-or.t @@ -5,7 +5,7 @@ use Test::More tests => 18; { package Foo; use Mouse; - use Mouse::TypeRegistry; + use Mouse::Util::TypeConstraints; subtype Baz => where { defined($_) && $_ eq 'Baz' }; coerce Baz => from 'ArrayRef', via { 'Baz' }; has 'bar' => ( is => 'rw', isa => 'Str | Baz | Undef', coerce => 1 ); @@ -51,7 +51,7 @@ is $f->bar, undef, 'bar is undef'; { package Bar; use Mouse; - use Mouse::TypeRegistry; + use Mouse::Util::TypeConstraints; subtype 'Type1' => where { defined($_) && $_ eq 'Name' }; coerce 'Type1', from 'Str', via { 'Names' }; @@ -74,7 +74,7 @@ is $foo->foo, 'Name', 'foo is Name'; { package Baz; use Mouse; - use Mouse::TypeRegistry; + use Mouse::Util::TypeConstraints; subtype 'Type3' => where { defined($_) && $_ eq 'Name' }; coerce 'Type3', from 'CodeRef', via { 'Name' }; diff --git a/t/800_shikabased/014-subtype-as.t b/t/800_shikabased/014-subtype-as.t index 8ee8ef0..263e5ac 100644 --- a/t/800_shikabased/014-subtype-as.t +++ b/t/800_shikabased/014-subtype-as.t @@ -16,7 +16,7 @@ use Scalar::Util qw/blessed/; { package Foo; use Mouse; - use Mouse::TypeRegistry; + use Mouse::Util::TypeConstraints; subtype 'Type1' => as 'Str' => where { blessed($_) }; has str_obj => (