fallback => 1;
use Scalar::Util qw(blessed refaddr);
+use Sub::Name qw(subname);
use base qw(Class::MOP::Object);
-our $VERSION = '0.73_01';
+our $VERSION = '0.79';
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
Moose->throw_error("Cannot coerce without a type coercion");
}
+ return $_[0] if $self->check($_[0]);
+
return $coercion->coerce(@_);
}
return $msg->($value);
}
else {
- $value = (defined $value ? overload::StrVal($value) : 'undef');
+ $value = (defined $value ? overload::StrVal($value) : 'undef');
return "Validation failed for '" . $self->name . "' failed with value $value";
- }
+ }
}
## type predicates ...
if ( $check == $null_constraint ) {
return $optimized_parent;
} else {
- return Class::MOP::subname($self->name, sub {
+ return subname($self->name, sub {
return undef unless $optimized_parent->($_[0]);
my (@args) = @_;
local $_ = $args[0];
# general case, check all the constraints, from the first parent to ourselves
my @checks = @parents;
push @checks, $check if $check != $null_constraint;
- return Class::MOP::subname($self->name => sub {
+ return subname($self->name => sub {
my (@args) = @_;
local $_ = $args[0];
foreach my $check (@checks) {
return $check if $check == $null_constraint; # Item, Any
- return Class::MOP::subname($self->name => sub {
+ return subname($self->name => sub {
my (@args) = @_;
local $_ = $args[0];
$check->(@args);
return $class->new(%opts, parent => $self);
}
-## this should get deprecated actually ...
-
-sub union { Carp::croak "DEPRECATED" }
-
1;
__END__