use Carp 'confess';
-our $VERSION = '0.01';
+our $VERSION = '0.02';
use base 'Class::MOP::Class';
# if nothing was in the %params, we can use the
# attribute's default value (if it has one)
$val ||= $attr->default($instance) if $attr->has_default;
- if (defined $val && $attr->has_type_constraint) {
- (defined $attr->type_constraint->($val))
- || confess "Attribute (" . $attr->name . ") does not pass the type contraint";
+ if (defined $val) {
+ if ($attr->has_type_constraint) {
+ if ($attr->should_coerce && $attr->type_constraint->has_coercion) {
+ $val = $attr->type_constraint->coercion->coerce($val);
+ }
+ (defined($attr->type_constraint->check($val)))
+ || confess "Attribute (" . $attr->name . ") does not pass the type contraint with '$val'";
+ }
}
$instance->{$attr->name} = $val;
}
=item B<construct_instance>
+=item B<mixed_in>
+
=back
=head1 BUGS