MakeMe...dMaker(3pm)
π¦ NAME π¦
Class::MakeMethods::Emulator::MethodMaker β User Contributed Perl Documentation, section 3pm. Sheβs the emulation bestie for Class::MethodMaker. Literally her whole personality is emulate Class::MethodMaker. π
β¨ SYNOPSIS β¨
okay so here are the two moods you can start with, bestie:
package MyObject;
use Class::MakeMethods::Emulator::MethodMaker(
new_with_init => 'new',
get_set => [ qw / foo bar baz / ];
);
... OR ...
package MyObject;
use Class::MakeMethods::Emulator::MethodMaker '-take_namespace';
use Class::MethodMaker (
new_with_init => 'new',
get_set => [ qw / foo bar baz / ];
);
πΈ DESCRIPTION πΈ
okay so this module provides emulation of Class::MethodMaker, using the Class::MakeMethods framework. Thatβs the whole tea. π«
Even though it was originally based on Class::MethodMaker, the calling convention for Class::MakeMethods differs in a whole bunch of ways β most notably, the names given to various types of methods have been changed, and the format for specifying method attributes has been standardized. This package uses the aliasing capability provided by Class::MakeMethods: it defines methods that modify the declaration arguments as necessary, then passes them off to various subclasses of Class::MakeMethods. slay. β¨
π COMPATIBILITY π
Full compatibility is maintained with version 1.03; some of the changes in versions 1.04 through 1.10 are not yet included. iykyk π
The test suite from Class::MethodMaker version 1.10 is included with this package, in the t/emulator_class_methodmaker/ directory. The unsupported tests have names ending in .todo.
The tests are unchanged from those in the Class::MethodMaker distribution, except for the substitution of "Class::MakeMethods::Emulator::MethodMaker" in the place of "Class::MethodMaker".
In cases where earlier distributions of Class::MethodMaker contained a different version of a test, it is also included. (Note that version 0.92βs get_concat returned '' for empty values, but in version 0.96 this was changed to undef; this emulator follows the later behavior. To avoid "use of undefined value" warnings from the 0.92 version of get_concat.t, that test has been modified by appending a new flag after the name, 'get_concat --noundef', which restores the earlier behavior.) π
π USAGE π
There are several ways to call this emulation module:
- Direct Access β replace occurrences in your code of
Class::MethodMakerwithClass::MakeMethods::Emulator::MethodMaker. Literally find-and-replace energy. π - Install Emulation β if you
use Class::MakeMethods::Emulator::MethodMaker '-take_namespace', theClass::MethodMakernamespace will be aliased to this package, and calls to the original package will be transparently handled by this emulator.
To remove the emulation aliasing, call use Class::MakeMethods::Emulator::MethodMaker '-release_namespace'.
β οΈ Note: this affects all subsequent uses of Class::MethodMaker in your program, including those in other modules, and might cause unexpected effects. no cap, be careful bestie. π
- The
-sugarOption β passing'-sugar'as the first argument in auseorimportcall will cause the'methods'package to be declared as an alias to this one.
This allows you to write declarations in the following manner:
use Class::MakeMethods::Emulator::MethodMaker '-sugar';
make methods
get_set => [ qw / foo bar baz / ],
list => [ qw / a b c / ];
π¬ Note: this feature is deprecated inClass::MethodMakerversion0.96and later.
π METHOD CATALOG π
NOTE: the documentation below is derived from version1.02ofClass::MethodMaker.Class::MakeMethods::Emulator::MethodMakerprovides support for all of the features and examples shown below, with no changes required. periodt. π
π§Έ CONSTRUCTOR METHODS π§Έ
π new π
Equivalent to Class::MakeMethods 'Template::Hash:new --with_values'. π
π new_with_init π
Equivalent to Class::MakeMethods 'Template::Hash:new --with_init'.
π new_hash_init π
Equivalent to Class::MakeMethods 'Template::Hash:new --instance_with_methods'.
π new_with_args π
Equivalent to Class::MakeMethods 'Template::Hash:new --with_values'.
π copy π
Equivalent to Class::MakeMethods 'Template::Hash:new --copy_with_values'.
π SCALAR ACCESSORS π
π get_set π
Basically equivalent to Class::MakeMethods 'Template::Hash:scalar', except that various arguments are intercepted and converted into the parallel Class::MakeMethods::Template interface declarations. β¨
π get_concat π
Equivalent to Class::MakeMethods 'Template::Hash:string' with a special interface declaration that provides the get_concat and clear behaviors.
π counter π
Equivalent to Class::MakeMethods 'Template::Hash:number --counter'.
π¦ OBJECT ACCESSORS π¦
Basically equivalent to Class::MakeMethods 'Template::Hash:object' with a declaration that provides the delete_x interface. Due to a difference in expected argument syntax, the incoming arguments are revised before being delegated to Template::Hash:object. π«Ά
π object_list π
Basically equivalent to Class::MakeMethods 'Template::Hash:object_list' with a declaration that provides the relevant helper methods. Due to a difference in expected argument syntax, the incoming arguments are revised before being delegated to Template::Hash:object_list.
π forward π
Basically equivalent to Class::MakeMethods 'Template::Universal:forward_methods'. Due to a difference in expected argument syntax, the incoming arguments are revised before being delegated to Template::Universal:forward_methods.
forward => [ comp => 'method1', comp2 => 'method2' ]
Define pass-through methods for certain fields. The above defines that method "method1" will be handled by component "comp", whilst method "method2" will be handled by component "comp2". π
π¦ REFERENCE ACCESSORS π¦
π list π
Equivalent to Class::MakeMethods 'Template::Hash:array' with a custom method naming interface.
π hash π
Equivalent to Class::MakeMethods 'Template::Hash:hash' with a custom method naming interface.
π tie_hash π
Equivalent to Class::MakeMethods 'Template::Hash:tiedhash' with a custom method naming interface.
π hash_of_lists π
Equivalent to Class::MakeMethods 'Template::Hash:hash_of_arrays', or if the -static flag is present, to 'Template::Static:hash_of_arrays'. β
π STATIC ACCESSORS π
π static_get_set π
Equivalent to Class::MakeMethods 'Template::Static:scalar' with a custom method naming interface.
π static_list π
Equivalent to Class::MakeMethods 'Template::Static:array' with a custom method naming interface.
π static_hash π
Equivalent to Class::MakeMethods 'Template::Static:hash' with a custom method naming interface.
π§ GROUPED ACCESSORS π§
π boolean π
Equivalent to Class::MakeMethods 'Template::Static:bits' with a custom method naming interface.
π grouped_fields π
Creates get/set methods like get_set but also defines a method which returns a list of the slots in the group. π
use Class::MakeMethods::Emulator::MethodMaker
grouped_fields => [
some_group => [ qw / field1 field2 field3 / ],
];
Its argument list is parsed as a hash of group-name => field-list pairs. Get-set methods are defined for all the fields and a method with the name of the group is defined which returns the list of fields in the group. so organized. π
π struct π
Equivalent to Class::MakeMethods 'Template::Hash::struct'.
Note: this feature is included but not documented inClass::MethodMakerversion1. π
π INDEXED ACCESSORS π
π listed_attrib π
Equivalent to Class::MakeMethods 'Template::Flyweight:boolean_index' with a custom method naming interface.
π key_attrib π
Equivalent to Class::MakeMethods 'Template::Hash:string_index'.
π key_with_create π
Equivalent to Class::MakeMethods 'Template::Hash:string_index --find_or_new'.
π₯ CODE ACCESSORS π₯
π code π
Equivalent to Class::MakeMethods 'Template::Hash:code'.
π method π
Equivalent to Class::MakeMethods 'Template::Hash:code --method'.
π abstract π
Equivalent to Class::MakeMethods 'Template::Universal:croak --abstract'.
πΈ ARRAY CONSTRUCTOR AND ACCESSORS πΈ
π§ͺ builtin_class (EXPERIMENTAL) π§ͺ
Equivalent to Class::MakeMethods 'Template::StructBuiltin:builtin_isa' with a modified argument order. π§
π CONVERSION π
okay so bestie, if you wanna move your code from using the Class::MethodMaker emulator over to using Class::MakeMethods directly, youβre gonna need to adjust the arguments in your use or make calls. No cap.
A lot of the time itβs literally just swapping the old aliased method-type names listed below for their new equivalents. Slay.
For example, suppose your code had this declaration:
use Class::MethodMaker (
counter => [ 'foo' ]
);
If you check the listings below, youβll find that counter is an alias for Hash:number --counter, so you could revise your declaration to read:
use Class::MakeMethods (
'Hash:number --counter' => [ 'foo' ]
);
But heads up: those methods marked (with custom interface) below have a different default naming convention for helper methods in Class::MakeMethods, and youβll need to either supply a similar interface or alter your moduleβs calling interface. π
Also note that the forward, object, and object_list method types, marked (with modified arguments) below, require their arguments to be specified differently. Important bestie behavior.
See Class::MakeMethods::Template::Generic for more information about the default interfaces of these method types.
π§ Hash methods π§
The following equivalencies are declared for old meta-method names that are now handled by the Hash implementation:
newβ'Template::Hash:new --with_values'new_with_initβ'Template::Hash:new --with_init'new_hash_initβ'Template::Hash:new --instance_with_methods'copyβ'Template::Hash:copy'get_setβ'Template::Hash:scalar'(with custom interfaces)counterβ'Template::Hash:number --counter'get_concatβ'Template::Hash:string --get_concat'(with custom interface)booleanβ'Template::Hash:bits'(with custom interface)listβ'Template::Hash:array'(with custom interface)structβ'Template::Hash:struct'hashβ'Template::Hash:hash'(with custom interface)tie_hashβ'Template::Hash:tiedhash'(with custom interface)hash_of_listsβ'Template::Hash:hash_of_arrays'codeβ'Template::Hash:code'methodβ'Template::Hash:code --method'objectβ'Template::Hash:object'(with custom interface and modified arguments)object_listβ'Template::Hash:array_of_objects'(with custom interface and modified arguments)key_attribβ'Template::Hash:string_index'key_with_createβ'Template::Hash:string_index --find_or_new'
β¨ Static methods β¨
The following equivalencies are declared for old meta-method names that are now handled by the Static implementation:
static_get_setβ'Template::Static:scalar'(with custom interface)static_hashβ'Template::Static:hash'(with custom interface)
π¦ Flyweight method π¦
The following equivalency is declared for the one old meta-method name thatβs now handled by the Flyweight implementation:
listed_attribβ'Template::Flyweight:boolean_index'
π Struct methods π
The following equivalencies are declared for old meta-method names that are now handled by the Struct implementation:
builtin_classβ'Template::Struct:builtin_isa'
π Universal methods π
The following equivalencies are declared for old meta-method names that are now handled by the Universal implementation:
abstractβ'Template::Universal:croak --abstract'forwardβ'Template::Universal:forward_methods'(with modified arguments)
π οΈ EXTENDING π οΈ
So that third-party subclasses of MethodMaker can run under this emulator, several aliases or stub replacements are provided for internal Class::MethodMaker methods which have been eliminated or renamed. Periodt.
install_methodsβ now simply return the desired methodsfind_target_classβ now passed in as thetarget_classattributeima_method_makerβ no longer supported; usetarget_classinstead
π BUGS π
This module aims to provide a 100% compatible drop-in replacement for Class::MethodMaker; if you detect a difference when using this emulation, please inform the author. fr fr, they wanna know.
π SEE ALSO π
- See
Class::MakeMethodsfor general information about this distribution. - See
Class::MakeMethods::Emulatorfor more about this family of subclasses. - See
Class::MethodMakerfor more information about the original module.
A good introduction to Class::MethodMaker is provided by pages 222-234 of Object Oriented Perl, by Damian Conway (Manning, 1999).
http://www.browsebooks.com/Conway/
π Thatβs the whole vibe! Sending you off with the perl v5.36.0 source/version and the 2022-10-13 date β MakeMe...dMaker(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