use Moose::Util::TypeConstraints;
use MooseX::Meta::TypeConstraint::Structured;
+use MooseX::Types::Structured::OverflowHandler;
use MooseX::Types -declare => [qw(Dict Tuple Optional)];
use Sub::Exporter -setup => { exports => [ qw(Dict Tuple Optional slurpy) ] };
use Devel::PartialDump;
+use Scalar::Util qw(blessed);
-our $VERSION = '0.10';
+our $VERSION = '0.155555';
our $AUTHORITY = 'cpan:JJNAPIORK';
=head1 NAME
@$type_constraints : ();
my $overflow_handler;
- if(ref $type_constraints[-1] eq 'CODE') {
+ if($type_constraints[-1] && blessed $type_constraints[-1]
+ && $type_constraints[-1]->isa('MooseX::Types::Structured::OverflowHandler')) {
$overflow_handler = pop @type_constraints;
}
## Make sure there are no leftovers.
if(@values) {
if($overflow_handler) {
- return $overflow_handler->([@values], $_[2]);
+ return $overflow_handler->check([@values], $_[2]);
} else {
$_[2]->{message} = "More values than Type Constraints!"
if ref $_[2];
@$type_constraints : ();
my $overflow_handler;
- if(ref $type_constraints[-1] eq 'CODE') {
+ if($type_constraints[-1] && blessed $type_constraints[-1]
+ && $type_constraints[-1]->isa('MooseX::Types::Structured::OverflowHandler')) {
$overflow_handler = pop @type_constraints;
}
my (%type_constraints) = @type_constraints;
## Make sure there are no leftovers.
if(%values) {
if($overflow_handler) {
- return $overflow_handler->(+{%values});
+ return $overflow_handler->check(+{%values});
} else {
$_[2]->{message} = "More values than Type Constraints!"
if ref $_[2];
Moose::Util::TypeConstraints::add_parameterizable_type($Optional);
}
-sub slurpy($) {
- my $tc = shift @_;
- return sub {
- $tc->check(shift);
- };
+sub slurpy ($) {
+ my ($tc) = @_;
+ return MooseX::Types::Structured::OverflowHandler->new(
+ type_constraint => $tc,
+ );
}
=head1 SEE ALSO
Want to break out the examples section to a separate cookbook style POD.
Want more examples and best practice / usage guidance for authors
Need to clarify deep coercions,
-Need to clarify subtypes of subtypes.
=head1 AUTHOR
+Copyright 2008-2009, John Napiorkowski <jjnapiork@cpan.org>
+
John Napiorkowski, C<< <jjnapiork@cpan.org> >>
+=head1 CONTRIBUTORS
+
+The Following people have contributed to this module:
+
+ Florian Ragwitz, C<< <rafl@debian.org> >>
+ Yuval Kogman, C<< <nothingmuch@woobling.org> >>
+
=head1 COPYRIGHT & LICENSE
+Copyright 2008-2009, John Napiorkowski <jjnapiork@cpan.org>
+
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.