1Class::MOP::Instance(3)User Contributed Perl DocumentatioCnlass::MOP::Instance(3)
2
3
4

NAME

6       Class::MOP::Instance - Instance Meta Object
7

SYNOPSIS

9         # for the most part, this protocol is internal
10         # and not for public usage, but this how one
11         # might use it
12
13         package Foo;
14
15         use strict;
16         use warnings;
17         use metaclass (
18             ':instance_metaclass'  => 'ArrayBasedStorage::Instance',
19         );
20
21         # now Foo->new produces blessed ARRAY ref based objects
22

DESCRIPTION

24       This is a sub-protocol which governs instance creation and access to
25       the slots of the instance structure.
26
27       This may seem like over-abstraction, but by abstracting this process
28       into a sub-protocol we make it possible to easily switch the details of
29       how an object's instance is stored with minimal impact. In most cases
30       just subclassing this class will be all you need to do (see the exam‐
31       ples; examples/ArrayBasedStorage.pod and examples/InsideOutClass.pod
32       for details).
33

METHODS

35       new ($meta, @attrs)
36           Creates a new instance meta-object and gathers all the slots from
37           the list of @attrs given.
38
39       meta
40           This will return a Class::MOP::Class instance which is related to
41           this class.
42
43       Creation of Instances
44
45       create_instance
46           This creates the appropriate structure needed for the instance and
47           then calls "bless_instance_structure" to bless it into the class.
48
49       bless_instance_structure ($instance_structure)
50           This does just exactly what it says it does.
51
52       clone_instance ($instance_structure)
53
54       Instrospection
55
56       NOTE: There might be more methods added to this part of the API, we
57       will add then when we need them basically.
58
59       associated_metaclass
60       get_all_slots
61           This will return the current list of slots based on what was given
62           to this object in "new".
63
64       is_valid_slot ($slot_name)
65
66       Operations on Instance Structures
67
68       An important distinction of this sub-protocol is that the instance
69       meta-object is a different entity from the actual instance it creates.
70       For this reason, any actions on slots require that the $instance_struc‐
71       ture is passed into them.
72
73       get_slot_value ($instance_structure, $slot_name)
74       set_slot_value ($instance_structure, $slot_name, $value)
75       initialize_slot ($instance_structure, $slot_name)
76       deinitialize_slot ($instance_structure, $slot_name)
77       initialize_all_slots ($instance_structure)
78       deinitialize_all_slots ($instance_structure)
79       is_slot_initialized ($instance_structure, $slot_name)
80       weaken_slot_value ($instance_structure, $slot_name)
81       strengthen_slot_value ($instance_structure, $slot_name)
82
83       Inlineable Instance Operations
84
85       This part of the API is currently un-used. It is there for use in
86       future experiments in class finailization mostly. Best to ignore this
87       for now.
88
89       is_inlinable
90           Each meta-instance should override this method to tell Class::MOP
91           if it's possible to inline the slot access.
92
93           This is currently only used by Class::MOP::Class::Immutable when
94           performing optimizations.
95
96       inline_create_instance
97       inline_slot_access ($instance_structure, $slot_name)
98       inline_get_slot_value ($instance_structure, $slot_name)
99       inline_set_slot_value ($instance_structure, $slot_name, $value)
100       inline_initialize_slot ($instance_structure, $slot_name)
101       inline_deinitialize_slot ($instance_structure, $slot_name)
102       inline_is_slot_initialized ($instance_structure, $slot_name)
103       inline_weaken_slot_value ($instance_structure, $slot_name)
104       inline_strengthen_slot_value ($instance_structure, $slot_name)
105

AUTHORS

107       Yuval Kogman <nothingmuch@woobling.com>
108
109       Stevan Little <stevan@iinteractive.com>
110
112       Copyright 2006, 2007 by Infinity Interactive, Inc.
113
114       <http://www.iinteractive.com>
115
116       This library is free software; you can redistribute it and/or modify it
117       under the same terms as Perl itself.
118
119
120
121perl v5.8.8                       2007-11-07           Class::MOP::Instance(3)
Impressum