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
27 implementations.
28
29 Subroutines are generated as closures bound to each method name.
30
31 Calling Conventions
32 When you "use" a subclass of this package, the method declarations you
33 provide as arguments cause subroutines to be generated and installed in
34 your module. You can also omit the arguments to "use" and instead make
35 methods at runtime by passing the declarations to a subsequent call to
36 make().
37
38 You may include any number of declarations in each call to "use" or
39 make(). If methods with the same name already exist, earlier calls to
40 "use" or make() win over later ones, but within each call, later
41 declarations superceed earlier ones.
42
43 You can install methods in a different package by passing "-TargetClass
44 => package" as your first arguments to "use" or "make".
45
46 See "USAGE" in Class::MakeMethods for more details.
47
48 Declaration Syntax
49 The following types of declarations are supported:
50
51 • generator_type => 'method_name'
52
53 • generator_type => 'name_1 name_2...'
54
55 • generator_type => [ 'name_1', 'name_2', ...]
56
57 For a list of the supported values of generator_type, see "BASIC
58 CLASSES" in Class::MakeMethods::Docs::Catalog, or the documentation for
59 each subclass.
60
61 For each method name you provide, a subroutine of the indicated type
62 will be generated and installed under that name in your module.
63
64 Method names should start with a letter, followed by zero or more
65 letters, numbers, or underscores.
66
68 See Class::MakeMethods for general information about this distribution.
69
70 For distribution, installation, support, copyright and license
71 information, see Class::MakeMethods::Docs::ReadMe.
72
73
74
75perl v5.36.0 2023-01-20 MakeMethods::Basic(3)