1 package MooseX::Meta::TypeConstraint::Role::Structured;
4 use Moose::Util::TypeConstraints;
5 requires qw(_normalize_args signature_equals);
9 MooseX::Meta::TypeConstraint::Role::Structured - Structured Type Constraints
17 our $VERSION = '0.01';
25 The following types are defined in this class.
27 =head2 Moose::Meta::TypeConstraint
29 Used to make sure we can properly validate incoming signatures.
33 class_type 'Moose::Meta::TypeConstraint';
37 This class defines the following attributes.
41 This is a signature of internal contraints for the contents of the outer
52 =head2 optional_signature
54 This is a signature of internal contraints for the contents of the outer
55 contraint container. These are optional constraints.
59 has 'optional_signature' => (
62 predicate=>'has_optional_signature',
67 This class defines the following methods.
69 =head2 _normalize_args
71 Get arguments into a known state or die trying. Ideally we try to make this
72 into a HashRef so we can match it up with the L</signature> HashRef.
76 The constraint is basically validating the L</signature> against the incoming
80 modifier to make sure equals descends into the L</signature>
84 around 'equals' => sub {
85 my ($equals, $self, $compared_type_constraint) = @_;
87 ## Make sure we are comparing typeconstraints of the same base class
88 return unless $compared_type_constraint->isa(__PACKAGE__);
90 ## Make sure the base equals is also good
91 return unless $self->$equals($compared_type_constraint);
93 ## Make sure the signatures match
94 return unless $self->signature_equals($compared_type_constraint);
96 ## If we get this far, the two are equal
100 =head2 signature_equals
102 Check that the signature equals another signature.
106 John James Napiorkowski <jjnapiork@cpan.org>
110 You may distribute this code under the same terms as Perl itself.