Moose::Meta::TypeConstraint - The Moose Type Constraint metaclass



NAME

Moose::Meta::TypeConstraint - The Moose Type Constraint metaclass


DESCRIPTION

This class represents a single type constraint. Moose's built-in type constraints, as well as constraints you define, are all store in a the Moose::Meta::TypeConstraint::Registry manpage object as objects of this class.


INHERITANCE

Moose::Meta::TypeConstraint is a subclass of the Class::MOP::Object manpage.


METHODS

Moose::Meta::TypeConstraint-new(%options) >>

This creates a new type constraint based on the provided %options:

$constraint-equals($type_name_or_object) >>

Returns true if the supplied name or type object is the same as the current type.

$constraint-is_subtype_of($type_name_or_object) >>

Returns true if the supplied name or type object is a parent of the current type.

$constraint-is_a_type_of($type_name_or_object) >>

Returns true if the given type is the same as the current type, or is a parent of the current type. This is a shortcut for checking equals and is_subtype_of.

$constraint-coerce($value) >>

This will attempt to coerce the value to the type. If the type does have any defined coercions this will throw an error.

$constraint-check($value) >>

Returns true if the given value passes the constraint for the type.

$constraint-validate($value) >>

This is similar to check. However, if the type is valid then the method returns an explicit undef. If the type is not valid, we call $self->get_message($value) internally to generate an error message.

$constraint-name >>

Returns the type's name, as provided to the constructor.

$constraint-parent >>

Returns the type's parent, as provided to the constructor, if any.

$constraint-has_parent >>

Returns true if the type has a parent type.

$constraint-parents >>

A synonym for parent. This is useful for polymorphism with types that can have more than one parent.

$constraint-constraint >>

Returns the type's constraint, as provided to the constructor.

$constraint-get_message($value) >>

This generates a method for the given value. If the type does not have an explicit message, we generate a default message.

$constraint-has_message >>

Returns true if the type has a message.

$constraint-message >>

Returns the type's message as a subroutine reference.

$constraint-coercion >>

Returns the type's the Moose::Meta::TypeCoercion manpage object, if one exists.

$constraint-has_coercion >>

Returns true if the type has a coercion.

$constraint-hand_optimized_type_constraint >>

Returns the type's hand optimized constraint, as provided to the constructor via the optimized option.

$constraint-has_hand_optimized_type_constraint >>

Returns true if the type has an optimized constraint.

$constraint-create_child_type(%options) >>

This returns a new type constraint of the same class using the provided %options. The parent option will be the current type.

This method exists so that subclasses of this class can override this behavior and change how child types are created.


BUGS

All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT.


AUTHOR

Stevan Little <stevan@iinteractive.com>


COPYRIGHT AND LICENSE

Copyright 2006-2009 by Infinity Interactive, Inc.

http://www.iinteractive.com

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

 Moose::Meta::TypeConstraint - The Moose Type Constraint metaclass