bump version to 0.66
[gitmo/Moose.git] / lib / Moose / Meta / TypeConstraint.pm
index 1c83eab..eff4449 100644 (file)
@@ -12,7 +12,7 @@ use Scalar::Util qw(blessed refaddr);
 
 use base qw(Class::MOP::Object);
 
-our $VERSION   = '0.62_02';
+our $VERSION   = '0.66';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -72,7 +72,13 @@ sub new {
 
 
 sub coerce   { ((shift)->coercion || Moose->throw_error("Cannot coerce without a type coercion"))->coerce(@_) }
-sub check    { $_[0]->_compiled_type_constraint->($_[1]) ? 1 : undef }
+
+sub check {
+    my ($self, @args) = @_;
+    my $constraint_subref = $self->_compiled_type_constraint;
+    return $constraint_subref->(@args) ? 1 : undef;
+}
+
 sub validate {
     my ($self, $value) = @_;
     if ($self->_compiled_type_constraint->($value)) {
@@ -210,8 +216,9 @@ sub _compile_subtype {
         } else {
             return Class::MOP::subname($self->name, sub {
                 return undef unless $optimized_parent->($_[0]);
-                local $_ = $_[0];
-                $check->($_[0]);
+                my (@args) = @_;
+                local $_ = $args[0];
+                $check->(@args);
             });
         }
     } else {
@@ -219,9 +226,10 @@ sub _compile_subtype {
         my @checks = @parents;
         push @checks, $check if $check != $null_constraint;
         return Class::MOP::subname($self->name => sub {
-            local $_ = $_[0];
+            my (@args) = @_;
+            local $_ = $args[0];
             foreach my $check (@checks) {
-                return undef unless $check->($_[0]);
+                return undef unless $check->(@args);
             }
             return 1;
         });
@@ -234,8 +242,9 @@ sub _compile_type {
     return $check if $check == $null_constraint; # Item, Any
 
     return Class::MOP::subname($self->name => sub {
-        local $_ = $_[0];
-        $check->($_[0]);
+        my (@args) = @_;
+        local $_ = $args[0];
+        $check->(@args);
     });
 }
 
@@ -335,7 +344,7 @@ The name of the type in the global type registry.
 
 =item B<parent>
 
-This type's parent  type.
+This type's parent type.
 
 =item B<has_parent>
 
@@ -343,18 +352,33 @@ Returns true if this type has a parent type.
 
 =item B<parents>
 
+Synonym for C<parent>.
+
 =item B<constraint>
 
+Returns this type's constraint.  This is the value of C<where> provided
+when defining a type.
+
 =item B<has_message>
 
+Returns true if this type has a message.
+
 =item B<message>
 
+Returns this type's message.
+
 =item B<get_message ($value)>
 
+Generate message for $value.
+
 =item B<has_coercion>
 
+Returns true if this type has a coercion.
+
 =item B<coercion>
 
+Returns this type's L<Moose::Meta::TypeCoercion> if one exists.
+
 =item B<hand_optimized_type_constraint>
 
 =item B<has_hand_optimized_type_constraint>
@@ -386,7 +410,7 @@ Stevan Little E<lt>stevan@iinteractive.comE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2006-2008 by Infinity Interactive, Inc.
+Copyright 2006-2009 by Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>