X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FMeta%2FTypeConstraint%2FDependent.pm;h=ae6ca56f9bafaec769c0ed8e417ddbffc027918c;hb=bcd7eb42f8aa35a7dfc81b2b7e749ee6af32c753;hp=40804949ab1d3c02e5cb7f4e2cf360af6a7b5de7;hpb=9b6d2e22998448b8c5a0817fb0d6a945ca0a9ea4;p=gitmo%2FMooseX-Dependent.git diff --git a/lib/MooseX/Meta/TypeConstraint/Dependent.pm b/lib/MooseX/Meta/TypeConstraint/Dependent.pm index 4080494..ae6ca56 100644 --- a/lib/MooseX/Meta/TypeConstraint/Dependent.pm +++ b/lib/MooseX/Meta/TypeConstraint/Dependent.pm @@ -63,6 +63,9 @@ However, the 'where' clause only get's the check value. Exercise some sanity, this should be limited to actual comparision operations, not as a sneaky way to mess with the constraining value. +This should return a Bool, suitable for ->check (That is true for valid, false +for fail). + =cut has 'comparison_callback' => ( @@ -234,6 +237,20 @@ around 'create_child_type' => sub { ); }; +=head2 constraint + +We modify constraint so that the value pass is automatically dereferenced + +=cut + +around 'constraint' => sub { + my ($constraint, $self) = @_; + return sub { + my ($arg) = @_; + $self->$constraint->($arg); + }; +}; + =head2 is_a_type_of =head2 is_subtype_of