Class::MOP::Method - Method Meta Object
| Use Case | Command | Description |
|---|---|---|
| ๐ง Create a method meta-object | Class::MOP::Method->wrap($code, %options) | Constructor from coderef or another method object |
| ๐ Clone a method | $metamethod->clone(%params) | Shallow clone sharing the same subroutine |
| ๐ Get the subroutine | $metamethod->body | Returns a reference to the method's subroutine |
| ๐ท๏ธ Get the method name | $metamethod->name | Returns the method's name (without package) |
| ๐ฆ Get the package name | $metamethod->package_name | Returns the method's package name |
| ๐ Get fully qualified name | $metamethod->fully_qualified_name | Returns "Package::Name::method" |
| ๐๏ธ Get associated metaclass | $metamethod->associated_metaclass | Returns the Class::MOP::Class object |
| ๐งฌ Get original method | $metamethod->original_method | Returns the method that was cloned |
| ๐ Get original name | $metamethod->original_name | Name from the first in the clone chain |
| ๐ฆ Get original package | $metamethod->original_package_name | Package from the first in the clone chain |
| ๐ Get original FQN | $metamethod->original_fully_qualified_name | Fully qualified name from the first in the clone chain |
| ๐งช Check if stub | $metamethod->is_stub | Returns true if method is sub foo; |
| ๐ Attach to class | $metamethod->attach_to_class($metaclass) | Set the associated metaclass (overwrites existing) |
| ๐ Detach from class | $metamethod->detach_from_class | Remove associated metaclass |
| โถ๏ธ Execute the method | $metamethod->execute(...) | Execute with provided arguments |
| ๐ช Get metaclass | Class::MOP::Method->meta | Returns a Class::MOP::Class instance for this class |
version 2.2200
The Method Protocol is very small, since methods in Perl 5 are just subroutines in a specific package. We provide a very basic introspection interface.
Class::MOP::Method->wrap($code, %options) โ ๐๏ธ Constructor. Accepts a method body as either a code reference or a Class::MOP::Method instance, followed by a hash of options.
name โ ๐ท๏ธ The method name (without package name). Required if $code is a coderef.package_name โ ๐ฆ The package name for the method. Required if $code is a coderef.associated_metaclass โ ๐ An optional Class::MOP::Class object. This is the metaclass for the method's class.$metamethod->clone(%params) โ ๐ Makes a shallow clone of the method object. The subroutine reference itself is shared between all clones. The original method object is available via original_method on the clone.$metamethod->body โ ๐ Returns a reference to the method's subroutine.$metamethod->name โ ๐ท๏ธ Returns the method's name.$metamethod->package_name โ ๐ฆ Returns the method's package name.$metamethod->fully_qualified_name โ ๐ Returns the method's fully qualified name (package name and method name).$metamethod->associated_metaclass โ ๐๏ธ Returns the Class::MOP::Class object for the method, if one exists.$metamethod->original_method โ ๐งฌ If this method object was created as a clone of some other method object, returns the object that was cloned.$metamethod->original_name โ ๐ Returns the method's original name, wherever it was first defined. For a chain of clones, returns the name from the first method in the chain.$metamethod->original_package_name โ ๐ฆ Returns the method's original package name, wherever it was first defined. For a chain of clones, returns the package name from the first method in the chain.$metamethod->original_fully_qualified_name โ ๐ Returns the method's original fully qualified name, wherever it was first defined. For a chain of clones, returns the fully qualified name from the first method in the chain.$metamethod->is_stub โ ๐งช Returns true if the method is just a stub: sub foo;$metamethod->attach_to_class($metaclass) โ ๐ Given a Class::MOP::Class object, sets the associated metaclass for the method. Overwrites any existing associated metaclass.$metamethod->detach_from_class โ ๐ Removes any associated metaclass object for the method.$metamethod->execute(...) โ โถ๏ธ Executes the method. Any arguments provided are passed on to the method itself.Class::MOP::Method->meta โ ๐ช Returns a Class::MOP::Class instance for this class. Class::MOP bootstraps this module by installing a number of attribute meta-objects into its metaclass.This software is copyright (c) 2006 by Infinity Interactive, Inc.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-24 01:30 @216.73.216.102
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)