| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Persistence::Attribute; |
|
2
|
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
147
|
use strict; |
|
|
17
|
|
|
|
|
76
|
|
|
|
17
|
|
|
|
|
742
|
|
|
4
|
17
|
|
|
17
|
|
81
|
use warnings; |
|
|
17
|
|
|
|
|
29
|
|
|
|
17
|
|
|
|
|
562
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
17
|
|
|
17
|
|
113
|
use Abstract::Meta::Class ':all'; |
|
|
17
|
|
|
|
|
43
|
|
|
|
17
|
|
|
|
|
3561
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
17
|
|
|
17
|
|
89
|
use vars qw($VERSION); |
|
|
17
|
|
|
|
|
34
|
|
|
|
17
|
|
|
|
|
671
|
|
|
9
|
17
|
|
|
17
|
|
108
|
use Carp 'confess'; |
|
|
17
|
|
|
|
|
38
|
|
|
|
17
|
|
|
|
|
3581
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$VERSION = 0.04; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
abstract_class; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Persistence::Attribute - Abstract class for MOP attribute object. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
package Employee; |
|
25
|
|
|
|
|
|
|
use Abstract::Meta::Class ':all'; |
|
26
|
|
|
|
|
|
|
use Persistence::ORM ':all'; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $orm = entity 'emp'; |
|
29
|
|
|
|
|
|
|
$orm->set_mop_attribute_adapter('Persistence::Attribute::MooseAdapter'); |
|
30
|
|
|
|
|
|
|
column empno => has('$.no') ; |
|
31
|
|
|
|
|
|
|
column ename => has('$.name'); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Interface to MOP attribute object adapters. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 EXPORT |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
None. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 ATTRIBUES |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=over |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item attribute |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Wraps MOP atrribute. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has '$.attribute'; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item column_name |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Column name. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
has '$.column_name'; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=back |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 METHODS |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=over |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item name |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Attribute name. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
abstract 'name'; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item accessor |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Accessor name - name of the method that returns value of the attribute. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $accessor = $attribute->accessor; |
|
84
|
|
|
|
|
|
|
my $value = $obj->$accessor; |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
abstract 'accessor'; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item mutator |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Mutator name - name of the method that sets value of the attribute. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $accessor = $attribute->mutator; |
|
96
|
|
|
|
|
|
|
$obj->$mutator($value); |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
abstract 'mutator'; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item storage_key |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Attribute storage key. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
If this option is set and object_creation_method is set to 'bless' |
|
107
|
|
|
|
|
|
|
then a new object creation will use bless method |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
bless { map {($_->storage_key, $args{$_->name})} @attributes}, $class |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
otherwise new method will be used. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
$class->new(map {($_->name, $args{$_->name})} @attributes); |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
abstract 'storage_key'; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item associated_class |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Name of the associated class. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
For isntance if you have relationship bettwen My::Employee object and My::Dept |
|
125
|
|
|
|
|
|
|
then associated_class will be My::Dept |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
abstract 'associated_class'; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item class_name |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Class to whom the attribute belongs. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
abstract 'class_name'; |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item get_value |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Returns value form object without triggering any events. |
|
144
|
|
|
|
|
|
|
Takes object as parameter. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
abstract 'get_value'; |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item set_value |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Sets object value without triggering any events. |
|
155
|
|
|
|
|
|
|
Takes object, value as parameter. |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
abstract 'set_value'; |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item has_value |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Returns true there is value, false otherwise. |
|
165
|
|
|
|
|
|
|
Takes object name as parameter. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
abstract 'has_value'; |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item find_attribute |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Returns attribute definition. |
|
175
|
|
|
|
|
|
|
Takes attribute name as parameter. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
abstract 'find_attribute'; |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item create_meta_attribute |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Retuns a new persisitence attribute object. |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
This method provides support for plain classes, and xml metadata. |
|
187
|
|
|
|
|
|
|
If the find attribute method can't find attribute for class then |
|
188
|
|
|
|
|
|
|
this method should be able to create a new one ad hoc. |
|
189
|
|
|
|
|
|
|
Takes hash ref with meta attriubtes properties, class name, column name. |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=cut |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
abstract 'create_meta_attribute'; |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=item install_fetch_interceptor |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
This method should instal lazy fetch decorator. |
|
199
|
|
|
|
|
|
|
It takes callback as parameters (code ref) |
|
200
|
|
|
|
|
|
|
This code ref takes $object referece and $value of the attribute. |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=cut |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
abstract 'install_fetch_interceptor'; |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
1; |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
__END__ |