1Mouse::Exporter(3)    User Contributed Perl Documentation   Mouse::Exporter(3)
2
3
4

NAME

6       Mouse::Exporter - make an import() and unimport() just like Mouse.pm
7

VERSION

9       This document describes Mouse version v2.5.10
10

SYNOPSIS

12           package MyApp::Mouse;
13
14           use Mouse ();
15           use Mouse::Exporter;
16
17           Mouse::Exporter->setup_import_methods(
18             as_is => [ 'has_rw', 'other_sugar', \&Some::Random::thing ],
19             also  => 'Mouse',
20           );
21
22           sub has_rw {
23               my $meta = caller->meta;
24               my ( $name, %options ) = @_;
25               $meta->add_attribute(
26                 $name,
27                 is => 'rw',
28                 %options,
29               );
30           }
31
32           # then later ...
33           package MyApp::User;
34
35           use MyApp::Mouse;
36
37           has 'name';
38           has_rw 'size';
39           thing;
40
41           no MyApp::Mouse;
42

DESCRIPTION

44       This module encapsulates the exporting of sugar functions in a
45       "Mouse.pm"-like manner. It does this by building custom "import",
46       "unimport" methods for your module, based on a spec you provide.
47
48       Note that "Mouse::Exporter" does not provide the "with_meta" option,
49       but you can easily get the metaclass by "caller->meta" as "SYNOPSIS"
50       shows.
51

METHODS

53   "setup_import_methods( ARGS )"
54   "build_import_methods( ARGS ) -> (\&import, \&unimport)"

SEE ALSO

56       Moose::Exporter
57
58
59
60perl v5.34.0                      2022-01-21                Mouse::Exporter(3)
Impressum