1MooseX::MarkAsMethods(3U)ser Contributed Perl DocumentatiMoonoseX::MarkAsMethods(3)
2
3
4

NAME

6       MooseX::MarkAsMethods - Mark overload code symbols as methods
7

SYNOPSIS

9           package Foo;
10           use Moose;
11
12           # mark overloads as methods and wipe other non-methods
13           use MooseX::MarkAsMethods autoclean => 1;
14
15           # define overloads, etc as normal
16
17           package Baz;
18           use Moose::Role
19           use MooseX::MarkAsMethods autoclean => 1;
20
21           # overloads defined in a role will "just work" when the role is
22           # composed into a class
23
24           # additional methods generated outside Class::MOP/Moose can be marked, too
25           __PACKAGE__->meta->mark_as_method('foo');
26
27           package Bar;
28           use Moose;
29
30           # order is important!
31           use namespace::autoclean;
32           use MooseX::MarkAsMethods;
33
34           # ...
35

DESCRIPTION

37       MooseX::MarkAsMethods allows one to easily mark certain functions as
38       Moose methods.  This will allow other packages such as
39       namespace::autoclean to operate without blowing away your overloads.
40       After using MooseX::MarkAsMethods your overloads will be recognized by
41       Class::MOP as being methods, and class extension as well as composition
42       from roles with overloads will "just work".
43
44       By default we check for overloads, and mark those functions as methods.
45
46       If 'autoclean => 1' is passed to import on use'ing this module, we will
47       invoke namespace::autoclean to clear out non-methods.
48

TRAITS APPLIED

50       use'ing this package causes a trait to be applied to your metaclass
51       (for both roles and classes), that provides a mark_as_method() method.
52       You can use this to mark newly generated methods at runtime (e.g.
53       during class composition) that some other package has created for you.
54
55       mark_as_method() is invoked with one or more names to mark as a method.
56       We die on any error (e.g. name not in symbol table, already a method,
57       etc).  e.g.
58
59           __PACKAGE__->meta->mark_as_method('newly_generated');
60
61       e.g. say you have some sugar from another package that creates
62       accessors of some sort; you could mark them as methods via a method
63       modifier:
64
65           # called as __PACKAGE__->foo_generator('name', ...)
66           after 'foo_generator' => sub {
67
68               shift->meta->mark_as_method(shift);
69           };
70

IMPLICATIONS FOR ROLES

72       Using MooseX::MarkAsMethods in a role will cause Moose to track and
73       treat your overloads like any other method defined in the role, and
74       things will "just work".  That's it.
75

CAVEATS

77   meta->mark_as_method()
78       You almost certainly don't need or want to do this.  CMOP/Moose are
79       fairly good about determining what is and what isn't a method, but not
80       perfect.  Before using this method, you should pause and think about
81       why you need to.
82
83   namespace::autoclean
84       As currently implemented, we run our "method maker" at the end of the
85       calling package's compile scope (B::Hooks::EndOfScope).  As
86       namespace::autoclean does the same thing, it's important that if
87       namespace::autoclean is used that it be use'd BEFORE
88       MooseX::MarkAsMethods, so that its end_of_scope block is run after
89       ours.
90
91       e.g.
92
93           # yes!
94           use namespace::autoclean;
95           use MooseX::MarkAsMethods;
96
97           # no -- overloads will be removed
98           use namespace::autoclean;
99           use MooseX::MarkAsMethods;
100
101       The easiest way to invoke this module and clean out non-methods without
102       having to worry about ordering is:
103
104           use MooseX::MarkAsMethods autoclean => 1;
105

SEE ALSO

107       overload, B::Hooks::EndOfScope, namespace::autoclean, Class::MOP,
108       Moose.
109
110       MooseX::Role::WithOverloading does allow for overload application from
111       roles, but it does this by copying the overload symbols from the (not
112       namespace::autoclean'ed role) the symbols handing overloads during
113       class composition; we work by marking the overloads as methods and
114       letting CMOP/Moose handle them.
115

AUTHOR

117       Chris Weyl, "<cweyl at alumni.drew.edu>"
118

BUGS

120       Please report any bugs or feature requests to "bug-moosex-markasmethods
121       at rt.cpan.org", or through the web interface at
122       http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-MarkAsMethods
123       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-MarkAsMethods>.
124

TODO

126       Additional testing is required, particularly where namespace::autoclean
127       is also being used.
128

SUPPORT

130       You can find documentation for this module with the perldoc command.
131
132           perldoc MooseX::MarkAsMethods
133
134       You can also look for information at:
135
136       ·   RT: CPAN's request tracker
137
138           http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-MarkAsMethods
139           <http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-MarkAsMethods>
140
141       ·   AnnoCPAN: Annotated CPAN documentation
142
143           http://annocpan.org/dist/MooseX-MarkAsMethods
144           <http://annocpan.org/dist/MooseX-MarkAsMethods>
145
146       ·   CPAN Ratings
147
148           http://cpanratings.perl.org/d/MooseX-MarkAsMethods
149           <http://cpanratings.perl.org/d/MooseX-MarkAsMethods>
150
151       ·   Search CPAN
152
153           http://search.cpan.org/dist/MooseX-MarkAsMethods/
154           <http://search.cpan.org/dist/MooseX-MarkAsMethods/>
155
157       Copyright (c) 2009, 2010, Chris Weyl "<cweyl@alumni.drew.edu>".
158
159       This library is free software; you can redistribute it and/or modify it
160       under the terms of the GNU Lesser General Public License as published
161       by the Free Software Foundation; either version 2.1 of the License, or
162       (at your option) any later version.
163
164       This library is distributed in the hope that it will be useful, but
165       WITHOUT ANY WARRANTY; without even the implied warranty of
166       MERCHANTABILITY or FITNESS OR A PARTICULAR PURPOSE.
167
168       See the GNU Lesser General Public License for more details.
169
170       You should have received a copy of the GNU Lesser General Public
171       License along with this library; if not, write to the
172
173           Free Software Foundation, Inc.,
174           59 Temple Place, Suite 330,
175           Boston, MA  02111-1307 USA
176
177
178
179perl v5.12.1                      2010-06-14          MooseX::MarkAsMethods(3)
Impressum