coercing method arguments in MooseX::Declare
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <753596831.2427405.1349116395946.JavaMail.root@sz0115a.emeryville.ca.mail.comcast.net> |
Hi,
I wonder if coercion works on method arguments when using MooseX::Declare?
I tried and could not make it work, maybe I expect too much.
use MooseX::Declare;
class Foo {
use Moose::Util::TypeConstraints;
subtype Target as 'Object' => where {
$_->can('update')
};
coerce Target => from 'Str' => via {
$_->new_with_options;
};
};
# How to specify coerce =>1 here ?
method add_target (Target $target! ) {
}
}