MakeMe...versal(3pm)
π NAME π
MakeMe...versal(3pm) β Class::MakeMethods::Standard::Universal - Generic Methods
okay so bestie, welcome to the universal-methods corner of the group chat π this page is literally about generic methods, and we are gonna get through every single detail together π«Ά
β¨ SYNOPSIS β¨
package MyObject;
use Class::MakeMethods::Standard::Universal (
no_op => 'this',
abstract => 'that',
delegate => { name=>'play_music', target=>'instrument', method=>'play' },
);
that's the synopsis, bestie β method types and names, exactly like that. π
π¦ DESCRIPTION π¦
The Standard::Universal suclass of MakeMethods provides a [INCOMPLETE].
yes, that's literally the text β βsuclassβ and [INCOMPLETE] included, we are not fixing the source π
π Calling Conventions π
When you use this package, the method names you provide as arguments cause subroutines to be generated and installed in your module.
See "Calling Conventions" in Class::MakeMethods::Standard for more information.
π Declaration Syntax π
To declare methods, pass in pairs of a method-type name followed by one or more method names.
Valid method-type names for this package are listed in "METHOD GENERATOR TYPES".
See "Declaration Syntax" in Class::MakeMethods::Standard and "Parameter Syntax" in Class::MakeMethods::Standard for more information.
π₯ METHOD GENERATOR TYPES π₯
π no_op - Placeholder π
For each method name passed, returns a subroutine with the following characteristics:
- Does nothing.
You might want to create and use such methods to provide hooks for subclass activity.
Sample declaration and usage:
package MyObject;
use Class::MakeMethods::Standard::Universal (
no_op => 'whatever',
);
...
# Doesn't do anything
MyObject->whatever();
π§ abstract - Placeholder π§
For each method name passed, returns a subroutine with the following characteristics:
- Fails with an error message.
This is intended to support the use of abstract methods, that must be overridden in a useful subclass.
If each subclass is expected to provide an implementation of a given method, using this abstract method will replace the generic error message below with the clearer, more explicit error message that follows it:
Can't locate object method "foo" via package "My::Subclass"
The "foo" method is abstract and can not be called on My::Subclass
However, note that the existence of this method will be detected by UNIVERSAL::can(), so it is not suitable for use in optional interfaces, for which you may wish to be able to detect whether the method is supported or not.
Sample declaration and usage:
package MyObject;
use Class::MakeMethods::Standard::Universal (
abstract => 'whatever',
);
...
package MySubclass;
sub whatever { ... }
# Failure
MyObject->whatever();
# Success
MySubclass->whatever();
π call_methods - Call methods by name π
For each method name passed, returns a subroutine with the following characteristics:
- Accepts a hash of key-value pairs, or a reference to hash of such pairs. For each pair, the key is interpreted as the name of a method to call, and the value is the argument to be passed to that method.
Sample declaration and usage:
package MyObject;
use Class::MakeMethods::Standard::Universal (
call_methods => 'init',
);
...
my $object = MyObject->new()
$object->init( foo => 'Foozle', bar => 'Barbados' );
# Equivalent to:
$object->foo('Foozle');
$object->bar('Barbados');
π§΅ join_methods - Concatenate results of other methods π§΅
For each method name passed, returns a subroutine with the following characteristics:
- Has a list of other methods names as an arrayref in the
'methods'parameter. Required. - When called, calls each of the named method on itself, in order, and returns the concatenation of their results.
- If a
'join'parameter is provided it is included between each method result. - If the
'skip_blanks'parameter is omitted, or is provided with a true value, removes all undefined or empty-string values from the results.
πͺ alias - Call another method πͺ
For each method name passed, returns a subroutine with the following characteristics:
- Calls another method on the same callee.
You might create such a method to extend or adapt your class' interface.
Sample declaration and usage:
package MyObject;
use Class::MakeMethods::Standard::Universal (
alias => { name=>'click_here', target=>'complex_machinery' }
);
sub complex_machinery { ... }
...
$myobj->click_here(...); # calls $myobj->complex_machinery(...)
π delegate - Use another object to provide method π
For each method name passed, returns a subroutine with the following characteristics:
- Calls a method on self to retrieve another object, and then calls a method on that object and returns its value.
You might want to create and use such methods to facilitate composition of objects from smaller objects.
Sample declaration and usage:
package MyObject;
use Class::MakeMethods::Standard::Universal (
'Standard::Hash:object' => { name=>'instrument' },
delegate => { name=>'play_music', target=>'instrument', method=>'play' }
);
...
my $object = MyObject->new();
$object->instrument( MyInstrument->new );
$object->play_music;
π SEE ALSO π
See Class::MakeMethods for general information about this distribution.
See Class::MakeMethods::Standard for more about this family of subclasses.
okay bestie, that's the whole page π«Άβ¨ β signing off from MakeMe...versal(3pm), source/version perl v5.36.0, dated 2022-10-13, and brought to you by User Contributed Perl Documentation. slay π
π¦ 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