1MakeMethods::Basic(3) User Contributed Perl DocumentationMakeMethods::Basic(3)
2
3
4
6 Class::MakeMethods::Basic - Make really simple methods
7
9 package MyObject;
10 use Class::MakeMethods::Basic::Hash (
11 'new' => [ 'new' ],
12 'scalar' => [ 'foo', 'bar' ]
13 );
14
15 package main;
16
17 my $obj = MyObject->new( foo => "Foozle", bar => "Bozzle" );
18 print $obj->foo();
19 $obj->bar("Barbados");
20
22 This document describes the various subclasses of Class::MakeMethods
23 included under the Basic::* namespace, and the method types each one
24 provides.
25
26 The Basic subclasses provide stripped-down method-generation implemen‐
27 tations.
28
29 Subroutines are generated as closures bound to each method name.
30
31 Calling Conventions
32
33 When you "use" a subclass of this package, the method declarations you
34 provide as arguments cause subroutines to be generated and installed in
35 your module. You can also omit the arguments to "use" and instead make
36 methods at runtime by passing the declarations to a subsequent call to
37 "make()".
38
39 You may include any number of declarations in each call to "use" or
40 "make()". If methods with the same name already exist, earlier calls to
41 "use" or "make()" win over later ones, but within each call, later dec‐
42 larations superceed earlier ones.
43
44 You can install methods in a different package by passing "-TargetClass
45 => package" as your first arguments to "use" or "make".
46
47 See "USAGE" in Class::MakeMethods for more details.
48
49 Declaration Syntax
50
51 The following types of declarations are supported:
52
53 · generator_type => 'method_name'
54
55 · generator_type => 'name_1 name_2...'
56
57 · generator_type => [ 'name_1', 'name_2', ...]
58
59 For a list of the supported values of generator_type, see "BASIC
60 CLASSES" in Class::MakeMethods::Docs::Catalog, or the documentation for
61 each subclass.
62
63 For each method name you provide, a subroutine of the indicated type
64 will be generated and installed under that name in your module.
65
66 Method names should start with a letter, followed by zero or more let‐
67 ters, numbers, or underscores.
68
70 See Class::MakeMethods for general information about this distribution.
71
72 For distribution, installation, support, copyright and license informa‐
73 tion, see Class::MakeMethods::Docs::ReadMe.
74
75
76
77perl v5.8.8 2004-09-06 MakeMethods::Basic(3)