1Class::MOP::Method(3) User Contributed Perl DocumentationClass::MOP::Method(3)
2
3
4
6 Class::MOP::Method - Method Meta Object
7
9 version 2.2011
10
12 The Method Protocol is very small, since methods in Perl 5 are just
13 subroutines in a specific package. We provide a very basic
14 introspection interface.
15
17 Class::MOP::Method->wrap($code, %options)
18 This is the constructor. It accepts a method body in the form of
19 either a code reference or a Class::MOP::Method instance, followed
20 by a hash of options.
21
22 The options are:
23
24 · name
25
26 The method name (without a package name). This is required
27 if $code is a coderef.
28
29 · package_name
30
31 The package name for the method. This is required if $code
32 is a coderef.
33
34 · associated_metaclass
35
36 An optional Class::MOP::Class object. This is the metaclass
37 for the method's class.
38
39 $metamethod->clone(%params)
40 This makes a shallow clone of the method object. In particular,
41 subroutine reference itself is shared between all clones of a given
42 method.
43
44 When a method is cloned, the original method object will be
45 available by calling "original_method" on the clone.
46
47 $metamethod->body
48 This returns a reference to the method's subroutine.
49
50 $metamethod->name
51 This returns the method's name.
52
53 $metamethod->package_name
54 This returns the method's package name.
55
56 $metamethod->fully_qualified_name
57 This returns the method's fully qualified name (package name and
58 method name).
59
60 $metamethod->associated_metaclass
61 This returns the Class::MOP::Class object for the method, if one
62 exists.
63
64 $metamethod->original_method
65 If this method object was created as a clone of some other method
66 object, this returns the object that was cloned.
67
68 $metamethod->original_name
69 This returns the method's original name, wherever it was first
70 defined.
71
72 If this method is a clone of a clone (of a clone, etc.), this
73 method returns the name from the first method in the chain of
74 clones.
75
76 $metamethod->original_package_name
77 This returns the method's original package name, wherever it was
78 first defined.
79
80 If this method is a clone of a clone (of a clone, etc.), this
81 method returns the package name from the first method in the chain
82 of clones.
83
84 $metamethod->original_fully_qualified_name
85 This returns the method's original fully qualified name, wherever
86 it was first defined.
87
88 If this method is a clone of a clone (of a clone, etc.), this
89 method returns the fully qualified name from the first method in
90 the chain of clones.
91
92 $metamethod->is_stub
93 Returns true if the method is just a stub:
94
95 sub foo;
96
97 $metamethod->attach_to_class($metaclass)
98 Given a Class::MOP::Class object, this method sets the associated
99 metaclass for the method. This will overwrite any existing
100 associated metaclass.
101
102 $metamethod->detach_from_class
103 Removes any associated metaclass object for the method.
104
105 $metamethod->execute(...)
106 This executes the method. Any arguments provided will be passed on
107 to the method itself.
108
109 Class::MOP::Method->meta
110 This will return a Class::MOP::Class instance for this class.
111
112 It should also be noted that Class::MOP will actually bootstrap
113 this module by installing a number of attribute meta-objects into
114 its metaclass.
115
117 · Stevan Little <stevan.little@iinteractive.com>
118
119 · Dave Rolsky <autarch@urth.org>
120
121 · Jesse Luehrs <doy@tozt.net>
122
123 · Shawn M Moore <code@sartak.org>
124
125 · יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
126
127 · Karen Etheridge <ether@cpan.org>
128
129 · Florian Ragwitz <rafl@debian.org>
130
131 · Hans Dieter Pearcey <hdp@weftsoar.net>
132
133 · Chris Prather <chris@prather.org>
134
135 · Matt S Trout <mst@shadowcat.co.uk>
136
138 This software is copyright (c) 2006 by Infinity Interactive, Inc.
139
140 This is free software; you can redistribute it and/or modify it under
141 the same terms as the Perl 5 programming language system itself.
142
143
144
145perl v5.28.1 2018-05-16 Class::MOP::Method(3)