Object::Pad::MOP::Class(3pm) | User Contributed Perl Documentation | Object::Pad::MOP::Class(3pm) |
"Object::Pad::MOP::Class" - meta-object representation of a "Object::Pad" class
Instances of this class represent a class or role implemented by Object::Pad. Accessors provide information about the class or role, and methods that can alter the class, typically by adding new elements to it, allow a program to extend existing classes.
Where possible, this API is designed to be compatible with MOP::Class.
This API should be considered experimental even within the overall context in which "Object::Pad" is expermental.
$bool = $metaclass->is_class $bool = $metaclass->is_role
Exactly one of these methods will return true, depending on whether this metaclass instance represents a true "class", or a "role".
$name = $metaclass->name
Returns the name of the class, as a plain string.
@classes = $metaclass->superclasses
Returns a list of superclasses, as Object::Pad::MOP::Class instances.
Because "Object::Pad" does not support multiple superclasses, this list will contain at most one item.
@roles = $metaclass->roles
Returns a list of roles implemented by this class, as Object::Pad::MOP::Class instances.
$metaclass->compose_role( $rolename ) $metaclass->compose_role( $rolemeta )
Adds a new role to the list of those implemented by the class.
The new role can be specified either as a plain string giving its name, or as an "Object::Pad::MOP::Class" meta instance directly.
$metaclass->add_BUILD( $code )
Adds a new "BUILD" block to the class, as a CODE reference.
$metamethod = $metaclass->add_method( $name, $code )
Adds a new named method to the class under the given name, as CODE reference.
Returns an instance of Object::Pad::MOP::Method to represent it.
$metamethod = $metaclass->get_own_method( $name )
Returns an instance of Object::Pad::MOP::Slot to represent the method of the given name, if one exists. If not an exception is thrown.
This can only see directly-applied methods; that is, methods created by the "method" keyword on the class itself, or added via "add_method". This will not see other names in the package stash, even if they contain a "CODE" slot, nor will it see methods inherited from a superclass.
$metaslot = $metaclass->add_slot( $name )
Adds a new slot to the class, using the given name (which must begin with the sigil character "$", "@" or "%").
Returns an instance of Object::Pad::MOP::Slot to represent it.
$metaslot = $metaclass->get_slot( $name )
Returns an instance of Object::Pad::MOP::Slot to represent the slot of the given name, if one exists. If not an exception is thrown.
Paul Evans <leonerd@leonerd.org.uk>
2021-02-20 | perl v5.32.1 |