1MakeMethods::Template::UIsnesridCeoOnuttr(i3b)uted PerlMDaokceuMmeetnhtoadtsi:o:nTemplate::InsideOut(3)
2
3
4
6 Class::MakeMethods::Template::InsideOut - External data
7
9 package MyObject;
10 use Class::MakeMethods::Template::InsideOut (
11 scalar => [ 'foo', 'bar' ]
12 );
13 sub new { ... }
14
15 package main;
16
17 my $obj = MyObject->new( foo => "Foozle", bar => "Bozzle" );
18 print $obj->foo(); # Prints Foozle
19 $obj->bar("Bamboozle"); # Sets $obj's bar value
20
22 Supports the Generic object constructor and accessors meta-method
23 types, but accepts any object as the underlying implementation type,
24 with member data stored in external indices.
25
26 Each method stores the values associated with various objects in an
27 hash keyed by the object's stringified identity. Since that hash is
28 accessible only from the generated closures, it is impossible for
29 foreign code to manipulate those values except through the method
30 interface.
31
32 A DESTROY method is installed to remove data for expired objects from
33 the various hashes. (If the DESTROY method is not called, your program
34 will not release this data and memory will be wasted.)
35
36 Common Parameters: The following parameters are defined for InsideOut
37 meta-methods.
38
39 data
40 An auto-vivified reference to a hash to be used to store the values
41 for each object.
42
43 Note that using InsideOut meta-methods causes the installation of a
44 DESTROY method in the calling class, which deallocates data for each
45 instance when it is discarded.
46
47 NOTE: This needs some more work to properly handle inheritance.
48
49 Standard Methods
50 The following methods from Generic are all supported:
51
52 scalar
53 string
54 string_index *
55 number
56 boolean
57 bits
58 array
59 hash
60 tiedhash
61 hash_of_arrays
62 object
63 instance
64 array_of_objects
65 code
66 code_or_scalar
67
68 See Class::MakeMethods::Template::Generic for the interfaces and
69 behaviors of these method types.
70
71 The items marked with a * above are specifically defined in this
72 package, whereas the others are formed automatically by the interaction
73 of this package's generic settings with the code templates provided by
74 the Generic superclass.
75
76 boolean_index
77 boolean_index => [ qw / foo bar baz / ]
78
79 Like InsideOut:boolean, boolean_index creates x, set_x, and clear_x
80 methods. However, it also defines a class method find_x which returns a
81 list of the objects which presently have the x-flag set to true.
82
83 Note that to free items from memory, you must clear these bits!
84
85
86
87perl v5.32.1 2021-01-27MakeMethods::Template::InsideOut(3)