Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Mouse CPAN distribution.

Report information
The Basics
Id: 59539
Status: resolved
Priority: 0/
Queue: Mouse

People
Owner: Nobody in particular
Requestors: vpit [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Implement Mouse::Util::TypeConstraints::register_type_constraint()
Hello. The attached patch implements Mouse::Util::TypeConstraints::register_type_constraint() since I need it, it's simple enough, and it's actually exported by Moose::Util::TC. I tried to use Moose's own error messages. I didn't know what was your policy about tests, so I didn't add any. Regards, Vincent Pit.
Subject: 0001-Implement-Mouse-Util-TypeConstraints-register_type_c.patch
From 9e44e9f3e88cf5b66b28e2aacd4fac5943bda39f Mon Sep 17 00:00:00 2001 From: Vincent Pit <perl@profvince.com> Date: Mon, 19 Jul 2010 17:14:58 +0200 Subject: [PATCH] Implement Mouse::Util::TypeConstraints::register_type_constraint() --- lib/Mouse/Util/TypeConstraints.pm | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/lib/Mouse/Util/TypeConstraints.pm b/lib/Mouse/Util/TypeConstraints.pm index ef8bd2f..3289de6 100644 --- a/lib/Mouse/Util/TypeConstraints.pm +++ b/lib/Mouse/Util/TypeConstraints.pm @@ -17,6 +17,7 @@ Mouse::Exporter->setup_import_methods( coerce find_type_constraint + register_type_constraint )], ); @@ -367,6 +368,16 @@ sub find_type_constraint { return $TYPE{$spec}; } +sub register_type_constraint { + my($constraint) = @_; + Carp::croak("No type supplied / type is not a valid type constraint") + unless Mouse::Util::is_a_type_constraint($constraint); + my $name = $constraint->name; + Carp::croak("can't register an unnamed type constraint") + unless defined $name; + return $TYPE{$name} = $constraint; +} + sub find_or_parse_type_constraint { my($spec) = @_; return $spec if Mouse::Util::is_a_type_constraint($spec); -- 1.7.0.4
Hi, Thank you. I have applied your patch and released Mouse 0.63. Mouse's test policy I think is to copy tests from Moose's distribution, fixing them as little as possible. In this case I did so. Regards, -- Goro Fuji (gfx) GFUJI at CPAN.org