use Moose::Meta::TypeCoercion::Union;
-our $VERSION = '0.55';
+our $VERSION = '0.72';
+$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
use base 'Moose::Meta::TypeConstraint';
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(
- name => (join ' | ' => map { $_->name } @{$options{type_constraints}}),
+ name => (join '|' => sort {$a cmp $b}
+ map { $_->name } @{$options{type_constraints}}),
parent => undef,
message => undef,
hand_optimized_type_constraint => undef,
return 0;
}
+sub create_child_type {
+ my ( $self, %opts ) = @_;
+
+ my $constraint
+ = Moose::Meta::TypeConstraint->new( %opts, parent => $self );
+
+ # if we have a type constraint union, and no
+ # type check, this means we are just aliasing
+ # the union constraint, which means we need to
+ # handle this differently.
+ # - SL
+ if ( not( defined $opts{constraint} )
+ && $self->has_coercion ) {
+ $constraint->coercion(
+ Moose::Meta::TypeCoercion::Union->new(
+ type_constraint => $self,
+ )
+ );
+ }
+
+ return $constraint;
+}
+
1;
__END__
=head1 DESCRIPTION
This metaclass represents a union of Moose type constraints. More
-details to be explained later (possibly in a Cookbook::Recipe).
+details to be explained later (possibly in a Cookbook recipe).
This actually used to be part of Moose::Meta::TypeConstraint, but it
is now better off in it's own file.
=back
-=head2 Overriden methods
+=head2 Overridden methods
=over 4
=item B<has_hand_optimized_type_constraint>
+=item B<create_child_type>
+
=back
=head1 BUGS
=head1 COPYRIGHT AND LICENSE
-Copyright 2006-2008 by Infinity Interactive, Inc.
+Copyright 2006-2009 by Infinity Interactive, Inc.
L<http://www.iinteractive.com>