Import MooseX :: Method :: Call Signatures

I created a “bundle” module that does a bunch of things: import Moose , import true , namespace::autoclean , makes the caller class immutable (taken from MooseX::AutoImmute ). The only thing I could not figure out was to enable MooseX::Method::Signatures .

Here is what I have 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 now I still need to add an additional use MooseX::Method::Signatures; . How to include this in my OO module?

+4
source share
1 answer

First of all, note that the implementation of Hook::AfterRuntime rather fragile. Although it works for many simple things, it’s very easy in the end it’s very difficult to debug errors. I would recommend just writing ->meta->make_immutable own or using other approaches to get around it, like MooseX::Declare .

To answer your real question:

 MooseX::Method::Signatures->setup_for($your_caller); 
+12
source

All Articles