|
NAMEClass::MakeMethods::Emulator::MethodMaker - Emulate Class::MethodMakerSYNOPSISpackage 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 / ]; ); DESCRIPTIONThis module provides emulation of Class::MethodMaker, using the Class::MakeMethods framework.Although originally based on Class::MethodMaker, the calling convention for Class::MakeMethods differs in a variety 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, defining methods that modify the declaration arguments as necessary and pass them off to various subclasses of Class::MakeMethods. COMPATIBILITYFull compatibility is maintained with version 1.03; some of the changes in versions 1.04 through 1.10 are not yet included.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.) USAGEThere are several ways to call this emulation module:
METHOD CATALOGNOTE: 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.CONSTRUCTOR METHODSnewEquivalent to Class::MakeMethods 'Template::Hash:new --with_values'.new_with_initEquivalent to Class::MakeMethods 'Template::Hash:new --with_init'.new_hash_initEquivalent to Class::MakeMethods 'Template::Hash:new --instance_with_methods'.new_with_argsEquivalent to Class::MakeMethods 'Template::Hash:new --with_values'.copyEquivalent to Class::MakeMethods 'Template::Hash:new --copy_with_values'.SCALAR ACCESSORSget_setBasically equivalent to Class::MakeMethods 'Template::Hash:scalar', except that various arguments are intercepted and converted into the parallel Class::MakeMethods::Template interface declarations.get_concatEquivalent to Class::MakeMethods 'Template::Hash:string' with a special interface declaration that provides the get_concat and clear behaviors.counterEquivalent to Class::MakeMethods 'Template::Hash:number --counter'.OBJECT ACCESSORSBasically equivalent to Class::MakeMethods 'Template::Hash:object' with an 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_listBasically equivalent to Class::MakeMethods 'Template::Hash:object_list' with an 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.forwardBasically 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 ACCESSORSlistEquivalent to Class::MakeMethods 'Template::Hash:array' with a custom method naming interface.hashEquivalent to Class::MakeMethods 'Template::Hash:hash' with a custom method naming interface.tie_hashEquivalent to Class::MakeMethods 'Template::Hash:tiedhash' with a custom method naming interface.hash_of_listsEquivalent to Class::MakeMethods 'Template::Hash:hash_of_arrays', or if the -static flag is present, to 'Template::Static:hash_of_arrays'.STATIC ACCESSORSstatic_get_setEquivalent to Class::MakeMethods 'Template::Static:scalar' with a custom method naming interface.static_listEquivalent to Class::MakeMethods 'Template::Static:array' with a custom method naming interface.static_hashEquivalent to Class::MakeMethods 'Template::Static:hash' with a custom method naming interface.GROUPED ACCESSORSbooleanEquivalent to Class::MakeMethods 'Template::Static:bits' with a custom method naming interface.grouped_fieldsCreates 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. structEquivalent to Class::MakeMethods 'Template::Hash::struct'.Note: This feature is included but not documented in Class::MethodMaker version 1. INDEXED ACCESSORSlisted_attribEquivalent to Class::MakeMethods 'Template::Flyweight:boolean_index' with a custom method naming interface.key_attribEquivalent to Class::MakeMethods 'Template::Hash:string_index'.key_with_createEquivalent to Class::MakeMethods 'Template::Hash:string_index --find_or_new'.CODE ACCESSORScodeEquivalent to Class::MakeMethods 'Template::Hash:code'.methodEquivalent to Class::MakeMethods 'Template::Hash:code --method'.abstractEquivalent to Class::MakeMethods 'Template::Universal:croak --abstract'.ARRAY CONSTRUCTOR AND ACCESSORSbuiltin_class (EXPERIMENTAL)Equivalent to Class::MakeMethods 'Template::StructBuiltin:builtin_isa' with a modified argument order.CONVERSIONIf you wish to convert your code from use of the Class::MethodMaker emulator to direct use of Class::MakeMethods, you will need to adjust the arguments specified in your "use" or "make" calls.Often this is simply a matter of replacing the names of aliased method-types listed below with the new equivalents. For example, suppose that you code contained the following declaration: use Class::MethodMaker ( counter => [ 'foo' ] ); Consulting the listings below you can find that "counter" is an alias for "Hash:number --counter" and you could thus revise your declaration to read: use Class::MakeMethods ( 'Hash:number --counter' => [ 'foo' ] ); However, note that those methods marked "(with custom interface)" below have a different default naming convention for helper methods in Class::MakeMethods, and you will 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. See Class::MakeMethods::Template::Generic for more information about the default interfaces of these method types. Hash methodsThe 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 methodsThe 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 methodThe following equivalency is declared for the one old meta-method name that us now handled by the Flyweight implementation:listed_attrib 'Template::Flyweight:boolean_index' Struct methodsThe following equivalencies are declared for old meta-method names that are now handled by the Struct implementation:builtin_class 'Template::Struct:builtin_isa' Universal methodsThe 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) EXTENDINGIn order to enable third-party subclasses of MethodMaker to run under this emulator, several aliases or stub replacements are provided for internal Class::MethodMaker methods which have been eliminated or renamed.
BUGSThis 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.SEE ALSOSee 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/
Visit the GSP FreeBSD Man Page Interface. |