-alias or -excludes caused a warning. However, passing other options is
totally valid when using MooseX::Role::Parameterized. (sartak)
+ * Allow regexp objects in duck_type constraints (to bring this in line with
+ the Object constraint)
+
2.0204 Thu, Aug 25, 2011
[BUG FIXES]
my $self = shift;
my $val = shift;
- return 'my $val = ' . $val . '; Scalar::Util::blessed($val) '
- . '&& Scalar::Util::blessed($val) ne "Regexp" '
- . '&& &List::MoreUtils::all('
- . 'sub { $val->can($_) }, '
+ return $self->parent->_inline_check($val)
+ . ' && do {' . "\n"
+ . 'my $val = ' . $val . ';' . "\n"
+ . '&List::MoreUtils::all(' . "\n"
+ . 'sub { $val->can($_) },' . "\n"
. join(', ', map { B::perlstring($_) } @{ $self->methods })
- . ')';
+ . ');' . "\n"
+ . '}';
};
sub new {
my @methods = @{ $args{methods} };
$args{constraint} = sub {
my $val = $_[0];
- blessed($val) && blessed($val) ne 'Regexp'
- && all { $val->can($_) } @methods;
+ return all { $val->can($_) } @methods;
};
$args{inlined} = $inliner;
return 1;
}
-sub constraint {
- my $self = shift;
-
- my @methods = @{ $self->methods };
-
- return sub {
- my $obj = shift;
- return all { $obj->can($_) } @methods
- };
-}
-
sub create_child_type {
my ($self, @args) = @_;
return Moose::Meta::TypeConstraint->new(@args, parent => $self);