Class:...:Method(3pm)
π Class::Meta::Method β the introspective method baddie π
okay bestie, welcome to the Class::Meta::Method page, part of the User Contributed Perl Documentation for Class:...:Method(3pm). she's a perl module and she's here to spill the tea on class method introspection. pull up a chair π«Ά
β¨ NAME β¨
Class::Meta::Method β Class::Meta class method introspection. literally her whole job. π
πΈ SYNOPSIS πΈ
# Assuming MyApp::Thingy was generated by Class::Meta.
my $class = MyApp::Thingy->my_class;
my $thingy = MyApp::Thingy->new;
print "\nMethods:\n";
for my $meth ($class->methods) {
print " o ", $meth->name, $/;
$meth->call($thingy);
}
like. look at her go. she's printing every method name and then calling it. main character energy fr. π
π¦ DESCRIPTION π¦
so this class hands you an interface to the Class::Meta objects that describe methods. she supports a simple description of the method, a label, and its visibility β and the visibility options are private, protected, trusted, or public. yes bestie, four whole vibes. π
now important: Class::Meta::Method objects are created by Class::Meta. they are never instantiated directly in client code. do not try it. i'm serious. π
so how do you get to them?? you call the my_class() method on a Class::Meta-generated class to retrieve its Class::Meta::Class object, and then you call the methods() method on that Class::Meta::Class object. that's the whole pipeline, no cap. β¨
π INTERFACE π
π Constructors π
newβ a protected method for constructing aClass::Meta::Methodobject. do NOT call this method directly!! instead, call theadd_method()method on aClass::Metaobject. that's the move. π
π Instance Methods π
name
my $name = $meth->name;
returns the method name. simple. iconic. π
package
my $package = $meth->package;
returns the method package.
desc
my $desc = $meth->desc;
returns the description of the method.
label
my $desc = $meth->label;
returns label for the method.
view
my $view = $meth->view;
returns the view of the method, reflecting its visibility. the possible values are defined by the following constants:
Class::Meta::PUBLICClass::Meta::PRIVATEClass::Meta::TRUSTEDClass::Meta::PROTECTEDcontext
my $context = $meth->context;
returns the context of the method β essentially whether it is a class or object method. the possible values are defined by the following constants:
Class::Meta::CLASSClass::Meta::OBJECTargsβ a description of the arguments to the method. this can be anything you like, but the recommendation is something like a string for a single argument, an array reference for a list of arguments, or a hash reference for parameter arguments. you do you bestie, but that's the suggested layout. πΈreturnsβ a description of the return value or values of the method.class
my $class = $meth->class;
returns the Class::Meta::Class object that this method is associated with. note that this object will always represent the class in which the method is defined, and not any of its subclasses. periodt. β
call
my $ret = $meth->call($obj, @args);
calls the method on the $obj object, passing in any arguments. heads up though: it uses a goto to execute the method, so the call to call() itself will not appear in a call stack trace. sneaky little thing. π
build
$meth->build($class);
this is a protected method, designed to be called only by the Class::Meta class or a subclass of Class::Meta. it takes a single argument: the Class::Meta::Class object for the class in which the method was defined. once it checks to make sure that it is only called by Class::Meta or a subclass of Class::Meta or of Class::Meta::Method, build() installs the method if it was specified via the code parameter to new().
and even though you should never call this method directly, subclasses of Class::Meta::Method may need to override it in order to add behavior. iykyk. π§
π«Ά SUPPORT π«Ά
this module is stored in an open GitHub repository at <http://github.com/theory/class-meta/>. feel free to fork and contribute! bestie behavior honestly. π
please file bug reports via GitHub Issues at <http://github.com/theory/class-meta/issues/> or by sending mail to bug-Class-Meta@rt.cpan.org (mailto:bug-Class-Meta@rt.cpan.org). π
β AUTHOR β
David E. Wheeler <david@justatheory.com>
π SEE ALSO π
other classes of interest within the Class::Meta distribution include:
Class::MetaClass::Meta::ClassClass::Meta::ConstructorClass::Meta::Attribute
go read those next, they're the whole squad. π₯
π COPYRIGHT AND LICENSE π
Copyright (c) 2002-2011, David E. Wheeler. Some Rights Reserved.
this module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's a wrap onClass:...:Method(3pm)bestie!! this page was served up byperl v5.34.0on2022-06-11β she's a lil vintage but she still slays πβ¨π
π¦ where this page comes from
- debian bookworm: libclass-meta-perl 0.66-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libclass-meta-perl 0.66-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libclass-meta-perl 0.66-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms