From: john napiorkowski Date: Fri, 22 May 2009 20:50:55 +0000 (-0400) Subject: started the custom coercion X-Git-Tag: 0.01~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=21df4517825e6c4bc201683264ecf7a3b8e25230;p=gitmo%2FMooseX-Dependent.git started the custom coercion --- diff --git a/lib/MooseX/Dependent/Meta/TypeCoercion/Dependent.pm b/lib/MooseX/Dependent/Meta/TypeCoercion/Dependent.pm index 991020e..a2b718d 100644 --- a/lib/MooseX/Dependent/Meta/TypeCoercion/Dependent.pm +++ b/lib/MooseX/Dependent/Meta/TypeCoercion/Dependent.pm @@ -1,12 +1,12 @@ package ## Hide from PAUSE - MooseX::Meta::TypeCoercion::Dependent; + MooseX::Dependent::Meta::TypeCoercion::Dependent; use Moose; extends 'Moose::Meta::TypeCoercion'; =head1 NAME -MooseX::Meta::TypeCoercion::Dependent - Coerce structured type constraints. +MooseX::Meta::TypeCoercion::Dependent - Coerce Dependent type constraints. =head1 DESCRIPTION diff --git a/lib/MooseX/Dependent/Meta/TypeConstraint/Dependent.pm b/lib/MooseX/Dependent/Meta/TypeConstraint/Dependent.pm index 12003dc..6b6a962 100644 --- a/lib/MooseX/Dependent/Meta/TypeConstraint/Dependent.pm +++ b/lib/MooseX/Dependent/Meta/TypeConstraint/Dependent.pm @@ -3,6 +3,7 @@ package ## Hide from PAUSE use Moose; use Moose::Util::TypeConstraints (); +use MooseX::Dependent::Meta::TypeCoercion::Dependent; use Scalar::Util qw(blessed); use Data::Dump; use Digest::MD5; @@ -70,6 +71,20 @@ has 'constraining_value' => ( This class defines the following methods. +=head2 BUILD + +Do some post build stuff + +=cut + +sub BUILD { + my ($self) = @_; + $self->coercion( + MooseX::Dependent::Meta::TypeCoercion::Dependent->new( + type_constraint => $self, + )); +} + =head2 parameterize (@args) Given a ref of type constraints, create a structured type. @@ -173,6 +188,8 @@ sub parameterize { parent_type_constraint=>$self->parent_type_constraint, constraining_value_type_constraint => $self->constraining_value_type_constraint, ); + + ## TODO This is probably going to have to go away (too many things added to the registry) Moose::Util::TypeConstraints::get_type_constraint_registry->add_type_constraint($type_constraint); return $type_constraint; } diff --git a/t/00-load.t b/t/00-load.t index 6166328..811a91f 100644 --- a/t/00-load.t +++ b/t/00-load.t @@ -1,5 +1,5 @@ -use Test::More tests=>3; { +use Test::More tests=>4; { use strict; use warnings; @@ -8,5 +8,6 @@ use Test::More tests=>3; { use_ok 'MooseX::Dependent'; use_ok 'MooseX::Dependent::Types'; use_ok 'MooseX::Dependent::Meta::TypeConstraint::Dependent'; + use_ok 'MooseX::Dependent::Meta::TypeCoercion::Dependent'; }