If someone has custom accessors with coercion, currently the accessor won't
be called and the coercion thus won't be applied to constructor arguments,
which are directly blessed into the object hash.
Should they be called if we can detect custom accessors? If not, we should
document a pattern to help people do this, such as in BUILD:
sub BUILD {
my $self = shift;
$self->$_( $self->{$_} ) for qw/baz bam/; # coerce custom
}
I worry that there's no way to know that a custom accessor is also a
mutator, so leaving it to the end user in BUILD might be the safest thing.
CC: @miyagawa
If someone has custom accessors with coercion, currently the accessor won't
be called and the coercion thus won't be applied to constructor arguments,
which are directly blessed into the object hash.
Should they be called if we can detect custom accessors? If not, we should
document a pattern to help people do this, such as in BUILD:
I worry that there's no way to know that a custom accessor is also a
mutator, so leaving it to the end user in BUILD might be the safest thing.
CC: @miyagawa