* Rename Mouse::TypeRegistry to Mouse::Util::TypeConstraints
+ * "type" sugar for when you're not subtyping anything
+
0.14 Sat Dec 20 16:53:05 2008
* POD fix
*{"$caller\::message"} = \&_message;
*{"$caller\::from"} = \&_from;
*{"$caller\::via"} = \&_via;
+ *{"$caller\::type"} = \&_type;
*{"$caller\::subtype"} = \&_subtype;
*{"$caller\::coerce"} = \&_coerce;
*{"$caller\::class_type"} = \&_class_type;
sub list_all_builtin_type_constraints { @SUBTYPE_KEYS }
}
+sub _type {
+ my $pkg = caller(0);
+ my($name, %conf) = @_;
+ if (my $type = $SUBTYPE{$name}) {
+ Carp::croak "The type constraint '$name' has already been created, cannot be created again in $pkg";
+ };
+ my $stuff = $conf{where} || do { $SUBTYPE{delete $conf{as} || 'Any' } };
+ $SUBTYPE{$name} = $stuff;
+}
+
sub _subtype {
my $pkg = caller(0);
my($name, %conf) = @_;
use Mouse;
use Mouse::Util::TypeConstraints;
- subtype 'HeadersType' => where { defined $_ && eval { $_->isa('Headers') } };
+ type 'HeadersType' => where { defined $_ && eval { $_->isa('Headers') } };
coerce 'HeadersType' =>
from 'HashRef' => via {
Headers->new(%{ $_ });