[Moose-commits] r7145 - in Mouse/trunk: . lib/Mouse/Util t
sartak at code2.0beta.co.uk
sartak at code2.0beta.co.uk
Mon Dec 22 02:36:38 GMT 2008
Author: sartak
Date: 2008-12-21 18:36:38 -0800 (Sun, 21 Dec 2008)
New Revision: 7145
Modified:
Mouse/trunk/
Mouse/trunk/Changes
Mouse/trunk/lib/Mouse/Util/TypeConstraints.pm
Mouse/trunk/t/501_moose_coerce_mouse.t
Log:
r77737 at onn: sartak | 2008-12-21 21:36:29 -0500
"type" sugar for when you're not subtyping anything
Property changes on: Mouse/trunk
___________________________________________________________________
Name: svk:merge
- 08e7d58d-de06-4458-8c15-335e402ab116:/local/Mouse:77734
08e7d58d-de06-4458-8c15-335e402ab116:/local/Mouse-trunk:61565
3efe9002-19ed-0310-8735-a98156148065:/Mouse/branches/shika-based:6997
+ 08e7d58d-de06-4458-8c15-335e402ab116:/local/Mouse:77737
08e7d58d-de06-4458-8c15-335e402ab116:/local/Mouse-trunk:61565
3efe9002-19ed-0310-8735-a98156148065:/Mouse/branches/shika-based:6997
Modified: Mouse/trunk/Changes
===================================================================
--- Mouse/trunk/Changes 2008-12-22 02:30:56 UTC (rev 7144)
+++ Mouse/trunk/Changes 2008-12-22 02:36:38 UTC (rev 7145)
@@ -5,6 +5,8 @@
* 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
Modified: Mouse/trunk/lib/Mouse/Util/TypeConstraints.pm
===================================================================
--- Mouse/trunk/lib/Mouse/Util/TypeConstraints.pm 2008-12-22 02:30:56 UTC (rev 7144)
+++ Mouse/trunk/lib/Mouse/Util/TypeConstraints.pm 2008-12-22 02:36:38 UTC (rev 7145)
@@ -21,6 +21,7 @@
*{"$caller\::message"} = \&_message;
*{"$caller\::from"} = \&_from;
*{"$caller\::via"} = \&_via;
+ *{"$caller\::type"} = \&_type;
*{"$caller\::subtype"} = \&_subtype;
*{"$caller\::coerce"} = \&_coerce;
*{"$caller\::class_type"} = \&_class_type;
@@ -85,6 +86,16 @@
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) = @_;
Modified: Mouse/trunk/t/501_moose_coerce_mouse.t
===================================================================
--- Mouse/trunk/t/501_moose_coerce_mouse.t 2008-12-22 02:30:56 UTC (rev 7144)
+++ Mouse/trunk/t/501_moose_coerce_mouse.t 2008-12-22 02:36:38 UTC (rev 7145)
@@ -22,7 +22,7 @@
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(%{ $_ });
More information about the Moose-commits
mailing list