use warnings;
use metaclass;
-our $VERSION = '0.89';
-$VERSION = eval $VERSION;
-our $AUTHORITY = 'cpan:STEVAN';
-
use base 'Moose::Meta::TypeConstraint';
use Moose::Meta::TypeConstraint::Parameterized;
use Moose::Util::TypeConstraints ();
+use Carp 'confess';
+
__PACKAGE__->meta->add_attribute('constraint_generator' => (
accessor => 'constraint_generator',
predicate => 'has_constraint_generator',
+ Class::MOP::_definition_context(),
+));
+
+__PACKAGE__->meta->add_attribute('inline_generator' => (
+ accessor => 'inline_generator',
+ predicate => 'has_inline_generator',
+ Class::MOP::_definition_context(),
));
sub generate_constraint_for {
};
}
+sub generate_inline_for {
+ my ($self, $type, $val) = @_;
+
+ confess "Can't generate an inline constraint for $type, since none "
+ . "was defined"
+ unless $self->has_inline_generator;
+
+ return '( do { ' . $self->inline_generator->( $self, $type, $val ) . ' } )';
+}
+
sub _parse_type_parameter {
my ($self, $type_parameter) = @_;
return Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($type_parameter);
if ( $contained_tc->isa('Moose::Meta::TypeConstraint') ) {
my $tc_name = $self->name . '[' . $contained_tc->name . ']';
return Moose::Meta::TypeConstraint::Parameterized->new(
- name => $tc_name,
- parent => $self,
- type_parameter => $contained_tc,
+ name => $tc_name,
+ parent => $self,
+ type_parameter => $contained_tc,
+ parameterized_from => $self,
);
}
else {
1;
+# ABSTRACT: Type constraints which can take a parameter (ArrayRef)
+
__END__
=pod
-=head1 NAME
-
-Moose::Meta::TypeConstraint::Parameterizable - Type constraints which can take a parameter (ArrayRef)
-
=head1 DESCRIPTION
This class represents a parameterizable type constraint. This is a
=head1 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.
-
-=head1 AUTHOR
-
-Stevan Little E<lt>stevan@iinteractive.comE<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 2006-2009 by Infinity Interactive, Inc.
-
-L<http://www.iinteractive.com>
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
+See L<Moose/BUGS> for details on reporting bugs.
=cut