ORM/MetapropBuilder.pm

filter: Statementstmt 32.2% 10 / 31 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 3 / 6 Podpod n/a totaltotal 25.4% 13 / 51 CC 8 SCAR 34.5
CC
8
Cov
22%
AUTOLOAD
56.0
__ANON__
6.0
BEGIN
1.2
CRAP 31.4
« ORM/History.pm ↑ Summary ORM.pm »
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 <akimov_alexey@sourceforge.net>
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 5 $VERSION=0.8;
32  
33 5 ▶use ORM::Metaprop;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 use overload
36 5 ▶ '-' => sub
Subroutine BEGIN: called CC=1 SCAR=2.2
37 0 ▶ {
Subroutine __ANON__: not called CC=2 SCAR=17.9
38 0 ▶ if( $_[0]{need_value} )
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]{'need_value'}) { } 0 0 0
39 {
40 (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 )->[0]{value};
46 }
47 else
48 {
49 0 $_[0]{prop};
50 }
51 },
52 5 fallback => 1;
53  
54 ##
55 ## CONSTRUCTORS
56 ##
57  
58 sub AUTOLOAD
59 0 ▶{
Subroutine AUTOLOAD: not called CC=7 SCAR=40.3
60 0 my $self = shift;
61 0 my %arg = @_;
62  
63 0 ▶ if( ref $self )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 0 0 0
64 {
65 0 my $prop = substr( $AUTOLOAD, rindex( $AUTOLOAD, '::' )+2 );
66  
67 0 ▶ if( $self->{prop} )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"prop"}) 0 0 0
68 {
69 0 ▶ if( $self->{prop}->_prop_ref_class )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'prop'}->_prop_ref_class) { } 0 0 0
70 {
71 0 ▶ if( $self->{prop}->_prop_ref_class->_has_prop( $prop ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'prop'}->_prop_ref_class->_has_prop($prop)) { } 0 0 0
72 {
73 0 ▶ unless( $self->{prop}->_expand( $prop, @_ ) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"prop"}->_expand($prop, @_)) 0 0 0
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 $self =
93 {
94 0 prop => ORM::Metaprop->_new_flat( class => $arg{prop_class} ),
95 };
96 0 ▶ if( $arg{need_value} )
Branch: 1 branch
BranchTrueFalseTotal
if ($arg{"need_value"}) 0 0 0
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 ▶{
Subroutine DESTROY: not called CC=1 SCAR=0.0
110 }
« ORM/History.pm ↑ Summary ORM.pm »