From: john napiorkowski Date: Sat, 23 May 2009 21:52:09 +0000 (-0400) Subject: documentation fixes X-Git-Tag: 0.01~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Dependent.git;a=commitdiff_plain;h=0af9bd45259a2013e6a3336d8944fb26170f164b documentation fixes --- diff --git a/lib/MooseX/Dependent/Meta/TypeCoercion/Dependent.pm b/lib/MooseX/Dependent/Meta/TypeCoercion/Dependent.pm index 5640267..8444aff 100644 --- a/lib/MooseX/Dependent/Meta/TypeCoercion/Dependent.pm +++ b/lib/MooseX/Dependent/Meta/TypeCoercion/Dependent.pm @@ -16,15 +16,12 @@ TBD This class defines the following methods. -=head +=head add_type_coercions -=cut +method modification to throw exception should we try to add a coercion on a +dependent type that's had it's constraining value filled -sub coerce { - my $self = shift @_; - my $coderef = $self->_compiled_type_coercion; - return $coderef->(@_); -} +=cut around 'add_type_coercions' => sub { my ($add_type_coercions, $self, @args) = @_; @@ -35,6 +32,14 @@ around 'add_type_coercions' => sub { } }; + +## These two are here until I can merge change upstream to Moose +sub coerce { + my $self = shift @_; + my $coderef = $self->_compiled_type_coercion; + return $coderef->(@_); +} + sub compile_type_coercion { my $self = shift; my @coercion_map = @{$self->type_coercion_map}; @@ -66,9 +71,6 @@ sub compile_type_coercion { }); } - - - =head1 SEE ALSO The following modules or resources may be of interest. diff --git a/lib/MooseX/Dependent/Meta/TypeConstraint/Dependent.pm b/lib/MooseX/Dependent/Meta/TypeConstraint/Dependent.pm index 1f1eb01..1b68da6 100644 --- a/lib/MooseX/Dependent/Meta/TypeConstraint/Dependent.pm +++ b/lib/MooseX/Dependent/Meta/TypeConstraint/Dependent.pm @@ -77,6 +77,9 @@ Do some post build stuff =cut +## Right now I add in the dependent type coercion until I can merge some Moose +## changes upstream + around 'new' => sub { my ($new, $class, @args) = @_; my $self = $class->$new(@args); @@ -256,6 +259,13 @@ around 'equals' => sub { } }; +=head2 is_subtype_of + +Method modifier to make sure we match on subtype for both the dependent type +as well as the type being made dependent + +=cut + around 'is_subtype_of' => sub { my ( $is_subtype_of, $self, $type_or_name ) = @_; @@ -271,11 +281,11 @@ around 'is_subtype_of' => sub { }; -sub is_a_type_of { - my ($self, @args) = @_; - return ($self->equals(@args) || - $self->is_subtype_of(@args)); -} +=head2 check + +As with 'is_subtype_of', we need to dual dispatch the method request + +=cut around 'check' => sub { my ($check, $self, @args) = @_; @@ -285,6 +295,12 @@ around 'check' => sub { ); }; +=head2 validate + +As with 'is_subtype_of', we need to dual dispatch the method request + +=cut + around 'validate' => sub { my ($validate, $self, @args) = @_; return ( @@ -293,6 +309,14 @@ around 'validate' => sub { ); }; +=head2 _compiled_type_constraint + +modify this method so that we pass along the constraining value to the constraint +coderef and also throw the correct error message if the constraining value does +not match it's requirement. + +=cut + around '_compiled_type_constraint' => sub { my ($method, $self, @args) = @_; my $coderef = $self->$method(@args); @@ -310,12 +334,18 @@ around '_compiled_type_constraint' => sub { }; }; -## if the constraining value has been added, no way to do a coercion. +=head2 coerce + +More method modification to support dispatch coerce to a parent. + +=cut + around 'coerce' => sub { my ($coerce, $self, @args) = @_; if($self->has_constraining_value) { push @args, $self->constraining_value; + ##Checking the type_coercion_map is probably evil if(@{$self->coercion->type_coercion_map}) { my $coercion = $self->coercion; warn "coercion map found in $coercion found for $self";