You know how Moose automatically turns on strict
and warnings
during import? I want to extend that behavior by turning on autodie
and use feature ':5.10'
in my Moose classes.
I've tracked down where Moose does this, in Moose::Exporter
, which assembles a custom import
sub for Moose that calls strict->import
and warnings->import
for the calling class.
However, I can't figure out a way to extend this import method in a Moose-ish way.
How should I handle this?
Since there are many ways a module might export its functions into the
use
-ing namespace, you may need to do some code digging in order to implement each desired library. What you're asking for isn't anything specific to Moose, so you can write your or your company's own best practices module which will set up a group of standards for you to work with, e.g.with
Autodie makes things a little more complicated since it relies on finding the use-er's package from caller() and uses the goto, but you may be able to find a better way with more testing. The more you implement, the more complicated this library might be, but it might be of high enough value for you to have the one-off solution that you can use within all you or your company's code.