MakeMe...ribute(3pm)
π¦ NAME π¦
Class::MakeMethods::Attribute β declare generated subs with attribute syntax. periodt. π
β¨ SYNOPSIS β¨
okay bestie, quick vibe check β this is literally MakeMe...ribute(3pm) from the User Contributed Perl Documentation, and here's the setup:
package MyObject;
use Class::MakeMethods::Attribute 'Standard::Hash';
sub new :MakeMethod('new');
sub foo :MakeMethod('scalar');
sub bar :MakeMethod('scalar', { hashkey => 'bar_data' });
sub debug :MakeMethod('Standard::Global:scalar');
πΈ DESCRIPTION πΈ
So Class::MakeMethods::Attribute is the package that lets common types of methods be generated via a subroutine attribute declaration. (Available in Perl 5.6 and later.) π
Adding the :MakeMethod() attribute to a subroutine declaration causes Class::MakeMethods to create and install a subroutine based on the parameters given to the :MakeMethod attribute. literally generated subs, no cap. β¨
You can declare a default method-generation class by passing the name of a MakeMethods subclass in the use Class::MakeMethods::Attribute statement. This default method-generation class will also apply as the default to any subclasses declared at compile time. If no default method-generation class is selected, you will need to fully-qualify all method type declarations. π
π EXAMPLE π
Here's a typical use of Class::MakeMethods::Attribute, bestie:
package MyObject;
use Class::MakeMethods::Attribute 'Standard::Hash';
sub new :MakeMethod('new');
sub foo :MakeMethod('scalar');
sub bar :MakeMethod('scalar', { hashkey => 'bar_data' });
sub debug :MakeMethod('Standard::Global:scalar');
package MySubclass;
use base 'MyObject';
sub bazzle :MakeMethod('scalar');
This is equivalent to the following explicit Class::MakeMethods invocations:
package MyObject;
use Class::MakeMethods (
-MakerClass => 'Standard::Hash',
new => 'new',
scalar => 'foo',
scalar => [ 'ba', { hashkey => 'bar_data' } ],
'Standard::Global:scalar' => 'debug',
);
package MySubclass;
use base 'MyObject';
use Class::MakeMethods (
-MakerClass => 'Standard::Hash',
scalar => 'bazzle',
);
π DIAGNOSTICS π
The following warnings and errors may be produced when using Class::MakeMethods::Attribute to generate methods. (Note that this list does not include run-time messages produced by calling the generated methods, or the standard messages produced by Class::MakeMethods.) π«Ά
Can't apply MakeMethod attribute to %s declaration.β You can not use the":MakeMethod"attribute with lexical or anonymous subroutine declarations.No method type provided for MakeMethod attribute.β You called":MakeMethod()"without the required method-type argument.
π SEE ALSO π
- See
Attribute::Handlersby Damian Conway. - See
Class::MakeMethodsfor general information about this distribution.
π and that's the whole vibe! this page came from perl v5.36.0, dated 2022-10-13 β MakeMe...ribute(3pm) out! π«Άβ¨
π¦ where this page comes from
- ubuntu noble: libclass-makemethods-perl 1.01-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libclass-makemethods-perl 1.01-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libclass-makemethods-perl 1.01-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms