MakeMe...dMaker(3pm)

πŸ“¦
version 1.01 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ¦‹ 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::MethodMaker with Class::MakeMethods::Emulator::MethodMaker. Literally find-and-replace energy. πŸ’…
  • Install Emulation β€” if you use Class::MakeMethods::Emulator::MethodMaker '-take_namespace', the Class::MethodMaker namespace 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 -sugar Option β€” passing '-sugar' as the first argument in a use or import call 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 in Class::MethodMaker version 0.96 and later.

πŸ‘‘ METHOD CATALOG πŸ‘‘

NOTE: the documentation below is derived from version 1.02 of Class::MethodMaker. Class::MakeMethods::Emulator::MethodMaker provides 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 in Class::MethodMaker version 1. πŸ™ˆ

πŸ’œ 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 methods
  • find_target_class β€” now passed in as the target_class attribute
  • ima_method_maker β€” no longer supported; use target_class instead

πŸ› 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::MakeMethods for general information about this distribution.
  • See Class::MakeMethods::Emulator for more about this family of subclasses.
  • See Class::MethodMaker for 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