line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# DESCRIPTION |
3
|
|
|
|
|
|
|
# PerlORM - Object relational mapper (ORM) for Perl. PerlORM is Perl |
4
|
|
|
|
|
|
|
# library that implements object-relational mapping. Its features are |
5
|
|
|
|
|
|
|
# much similar to those of Java's Hibernate library, but interface is |
6
|
|
|
|
|
|
|
# much different and easier to use. |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# AUTHOR |
9
|
|
|
|
|
|
|
# Alexey V. Akimov |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# COPYRIGHT |
12
|
|
|
|
|
|
|
# Copyright (C) 2005-2006 Alexey V. Akimov |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# This library is free software; you can redistribute it and/or |
15
|
|
|
|
|
|
|
# modify it under the terms of the GNU Lesser General Public |
16
|
|
|
|
|
|
|
# License as published by the Free Software Foundation; either |
17
|
|
|
|
|
|
|
# version 2.1 of the License, or (at your option) any later version. |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
# This library is distributed in the hope that it will be useful, |
20
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
21
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
22
|
|
|
|
|
|
|
# Lesser General Public License for more details. |
23
|
|
|
|
|
|
|
# |
24
|
|
|
|
|
|
|
# You should have received a copy of the GNU Lesser General Public |
25
|
|
|
|
|
|
|
# License along with this library; if not, write to the Free Software |
26
|
|
|
|
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
27
|
|
|
|
|
|
|
# |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
package ORM::MetapropBuilder; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$VERSION=0.8; |
32
|
|
|
|
|
|
|
|
33
|
5
|
|
|
5
|
|
27
|
use ORM::Metaprop; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
248
|
|
34
|
5
|
|
|
5
|
|
30
|
use Carp; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
864
|
|
35
|
|
|
|
|
|
|
use overload |
36
|
|
|
|
|
|
|
'-' => sub |
37
|
|
|
|
|
|
|
{ |
38
|
0
|
0
|
|
0
|
|
|
if( $_[0]{need_value} ) |
39
|
|
|
|
|
|
|
{ |
40
|
0
|
|
|
|
|
|
(ref $_[0]{need_value})->stat |
41
|
|
|
|
|
|
|
( |
42
|
|
|
|
|
|
|
data => { value=>$_[0]{prop} }, |
43
|
|
|
|
|
|
|
filter => ( $_[0]{need_value}->M('id') == $_[0]{need_value}->id ), |
44
|
|
|
|
|
|
|
error => $_[0]{error}, |
45
|
|
|
|
|
|
|
)->[0]{value}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
else |
48
|
|
|
|
|
|
|
{ |
49
|
0
|
|
|
|
|
|
$_[0]{prop}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
}, |
52
|
5
|
|
|
5
|
|
29
|
fallback => 1; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
73
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
## |
55
|
|
|
|
|
|
|
## CONSTRUCTORS |
56
|
|
|
|
|
|
|
## |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub AUTOLOAD |
59
|
|
|
|
|
|
|
{ |
60
|
0
|
|
|
0
|
|
|
my $self = shift; |
61
|
0
|
|
|
|
|
|
my %arg = @_; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if( ref $self ) |
64
|
|
|
|
|
|
|
{ |
65
|
0
|
|
|
|
|
|
my $prop = substr( $AUTOLOAD, rindex( $AUTOLOAD, '::' )+2 ); |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
if( $self->{prop} ) |
68
|
|
|
|
|
|
|
{ |
69
|
0
|
0
|
|
|
|
|
if( $self->{prop}->_prop_ref_class ) |
70
|
|
|
|
|
|
|
{ |
71
|
0
|
0
|
|
|
|
|
if( $self->{prop}->_prop_ref_class->_has_prop( $prop ) ) |
72
|
|
|
|
|
|
|
{ |
73
|
0
|
0
|
|
|
|
|
unless( $self->{prop}->_expand( $prop, @_ ) ) |
74
|
|
|
|
|
|
|
{ |
75
|
0
|
|
|
|
|
|
croak "Failed to expand property '$prop' for ".$self->{prop}->_prop_ref_class; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
else |
79
|
|
|
|
|
|
|
{ |
80
|
0
|
|
|
|
|
|
$self->{prop} = $self->{prop}->$prop( @_ ); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
else |
84
|
|
|
|
|
|
|
{ |
85
|
0
|
|
|
|
|
|
$self->{prop} = $self->{prop}->$prop( @_ ); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
else |
90
|
|
|
|
|
|
|
{ |
91
|
0
|
|
|
|
|
|
my $class = $self; |
92
|
0
|
|
|
|
|
|
$self = |
93
|
|
|
|
|
|
|
{ |
94
|
|
|
|
|
|
|
prop => ORM::Metaprop->_new_flat( class => $arg{prop_class} ), |
95
|
|
|
|
|
|
|
}; |
96
|
0
|
0
|
|
|
|
|
if( $arg{need_value} ) |
97
|
|
|
|
|
|
|
{ |
98
|
0
|
|
|
|
|
|
$self->{need_value} = $arg{need_value}; |
99
|
0
|
|
|
|
|
|
$self->{error} = $arg{error}; |
100
|
|
|
|
|
|
|
} |
101
|
0
|
|
|
|
|
|
bless $self, $class; |
102
|
|
|
|
|
|
|
#print "Init builder ($self).\n"; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
return $self; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub DESTROY |
109
|
0
|
|
|
0
|
|
|
{ |
110
|
|
|
|
|
|
|
} |