$code .= "if (exists \$args->{'$from'}) {\n";
if ($attr->should_coerce && $attr->type_constraint) {
- $code .= "my \$value = Mouse::Util::TypeConstraints->typecast_constraints('".$attr->associated_class->name."', \$attrs[$index]->{find_type_constraint}, \$attrs[$index]->{type_constraint}, \$args->{'$from'});\n";
+ $code .= "my \$value = Mouse::Util::TypeConstraints->typecast_constraints('".$attr->associated_class->name."', \$attrs[$index]->{type_constraint}, \$attrs[$index]->{type_constraint}, \$args->{'$from'});\n";
}
else {
$code .= "my \$value = \$args->{'$from'};\n";
if ($attr->has_type_constraint) {
$code .= "{
- local \$_ = \$value;
- unless (\$attrs[$index]->{find_type_constraint}->(\$_)) {
+ unless (\$attrs[$index]->{type_constraint}->check(\$value)) {
\$attrs[$index]->verify_type_constraint_error('$key', \$_, \$attrs[$index]->type_constraint)
}
}";
$code .= "my \$value = ";
if ($attr->should_coerce && $attr->type_constraint) {
- $code .= "Mouse::Util::TypeConstraints->typecast_constraints('".$attr->associated_class->name."', \$attrs[$index]->{find_type_constraint}, \$attrs[$index]->{type_constraint}, ";
+ $code .= "Mouse::Util::TypeConstraints->typecast_constraints('".$attr->associated_class->name."', \$attrs[$index]->{type_constraint}, \$attrs[$index]->{type_constraint}, ";
}
if ($attr->has_builder) {
if ($attr->has_type_constraint) {
$code .= "{
- local \$_ = \$value;
- unless (\$attrs[$index]->{find_type_constraint}->(\$_)) {
+ unless (\$attrs[$index]->{type_constraint}->check(\$value)) {
\$attrs[$index]->verify_type_constraint_error('$key', \$_, \$attrs[$index]->type_constraint)
}
}";
return <<'...';
do {
if ( scalar @_ == 1 ) {
- if ( defined $_[0] ) {
- ( ref( $_[0] ) eq 'HASH' )
+ ( ref( $_[0] ) eq 'HASH' )
|| Carp::confess "Single parameters to new() must be a HASH ref";
- +{ %{ $_[0] } };
- }
- else {
- +{};
- }
+ +{ %{ $_[0] } };
}
else {
+{@_};