-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)
+
[DEPRECATIONS]
* The optimize_as option for type constraints has been deprecated. Use the
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);