I've ma开发者_高级运维de a "bundle" module which does a bunch of things: imports Moose, imports true, namespace::autoclean, makes the caller's class immutable (taken from MooseX::AutoImmute). The one thing I haven't been able to figure out is how to include MooseX::Method::Signatures.
Here's what I've got so far:
package My::OO;
use Moose::Exporter;
use Hook::AfterRuntime;
use Moose ();
use true ();
use namespace::autoclean ();
my ($import, $unimport, $init_meta) = Moose::Exporter->build_import_methods(
 also => ['Moose'],
);
sub import {
 true->import();
 my $caller = scalar caller;
 after_runtime { $caller->meta->make_immutable };
 namespace::autoclean->import(-cleanee => $caller);
 goto &$import;
}
sub unimport {
 goto &$unimport;
}
1;
The idea is that in my code, I can now do things like this:
package My::Class; {
    use My::OO;
    extends 'My::Parent';
    method foo() { ... }
}
but right now I still have to include an extra use MooseX::Method::Signatures;. How can I include that into my OO module?
First off, please note that the implementation of Hook::AfterRuntime is quite fragile. While it works for many simple things, it's extremely easy to end up with very hard to debug errors. I'd recommend just writing the ->meta->make_immutable yourself, or using other approaches to get around writing it, like MooseX::Declare, for example.
To answer your actual question:
MooseX::Method::Signatures->setup_for($your_caller);
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论