1MakeMethods::Emulator::USsterrucCto(n3t)ributed Perl DocMuamkeenMteatthioodns::Emulator::Struct(3)
2
3
4
6 Class::MakeMethods::Emulator::Struct - Emulate Class::Struct
7
9 use Class::MakeMethods::Emulator::Struct;
10
11 struct (
12 simple => '$',
13 ordered => '@',
14 mapping => '%',
15 obj_ref => 'FooObject'
16 );
17
19 This module emulates the functionality of Class::Struct by munging the
20 provided field-declaration arguments to match those expected by
21 Class::MakeMethods.
22
23 It supports the same four types of accessors, the choice of array-based
24 or hash-based objects, and the choice of installing methods in the
25 current package or a specified target.
26
28 The below three declarations create equivalent methods for a simple
29 hash-based class with a constructor and four accessors.
30
31 use Class::Struct;
32 struct (
33 simple => '$',
34 ordered => '@',
35 mapping => '%',
36 obj_ref => 'FooObject'
37 );
38
39 use Class::MakeMethods::Emulator::Struct;
40 struct (
41 simple => '$',
42 ordered => '@',
43 mapping => '%',
44 obj_ref => 'FooObject'
45 );
46
47 use Class::MakeMethods (
48 -MakerClass => 'Standard::Array',
49 'new' => 'new',
50 'scalar' => 'simple',
51 'array -auto_init 1' => 'ordered',
52 'hash -auto_init 1' => 'mapping',
53 'object -auto_init 1' => '-class FooObject obj_ref'
54 );
55
57 This module aims to offer a "95% compatible" drop-in replacement for
58 the core Class::Struct module for purposes of comparison and code
59 migration.
60
61 The "class-struct.t" test for the core Class::Struct module is included
62 with this package. The test is unchanged except for the a direct
63 substitution of this emulator's name in the place of the core module.
64
65 However, there are numerous internal differences between the methods
66 generated by the original Class::Struct and this emulator, and some
67 existing code may not work correctly without modification.
68
70 See Class::MakeMethods for general information about this distribution.
71
72 See Class::MakeMethods::Emulator for more about this family of
73 subclasses.
74
75 See Class::Struct for documentation of the original module.
76
77 See Class::MakeMethods::Standard::Hash and
78 Class::MakeMethods::Standard::Array for documentation of the created
79 methods.
80
81
82
83perl v5.32.0 2020-07-28 MakeMethods::Emulator::Struct(3)