Romani/Query/Function.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 36 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
get_arguments
2.0
add
2.0
CRAP 2.0
1  
2 package DBIx::Romani::Query::Function;
3  
4 =begin xmldoc
5  
6 <name> DBIx::Romani::Query::Function </name>
7  
8 <synopsis>
9 # Don't use directy, create a sub-class!
10 use DBIx::Romani::Query::Function;
11 my $func = DBIx::Romani::Query::Function->new();
12 $func->add( DBIx::Romani::Query::SQL::Column->new('column_name') );
13 </synopsis>
14  
15 <description>
16 The parent class of all query functions. A query function is something
17 like COUNT() in SQL, but can include control flow functions that are
18 executed in the query engine and not in SQL. This class is abstract and
19 can't be used directly.
20 </description>
21  
22 =cut
23  
24 use strict;
25  
26 =begin xmldoc
27  
28 <sub type="constructor">
29 <name> new() </name>
30 <purpose> Constructs a new query object </purpose>
31 <arguments> none </arguments>
32 </sub>
33  
34 =cut
35 sub new
36 {
37 my $class = shift;
38 my $args = shift;
39  
40 my $self = {
41 arguments => [ ]
42 };
43  
44 bless $self, $class;
45 return $self;
46 }
47  
48 =begin xmldoc
49  
50 <sub type="method">
51 <name> get_arguments() </name>
52 <purpose> Gets the argument list. </purpose>
53 <returns> A list reference. </returns>
54 <arguments> none </arguments>
55 </sub>
56  
57 =cut
58 sub get_arguments { return shift->{arguments}; }
59  
60 =begin xmldoc
61  
62 <sub type="method">
63 <name> add() </name>
64 <purpose> Add an object to the argument list </purpose>
65 <arguments> object </arguments>
66 </sub>
67  
68 =cut
69 sub add
70 {
71 my ($self, $arg) = @_;
72 push @{$self->{arguments}}, $arg;
73 }
74  
75 =begin xmldoc
76  
77 <sub type="method">
78 <name> visit() </name>
79 <purpose> Abstract method to "execute" the function </purpose>
80 <arguments> visitor </arguments>
81 <returns> The result of the function </returns>
82 </sub>
83  
84 =cut
85 sub visit
86 {
87 die "Abstract.";
88 }
89  
90 sub copy_arguments
91 {
92 my ($self, $other) = @_;
93  
94 foreach my $arg ( @{$other->get_arguments()} )
95 {
96 $self->add_arguments( $arg->clone() );
97 }
98 }
99  
100 sub clone
101 {
102 my $self = shift;
103 my $class = ref($self);
104  
105 my $clone;
106 $clone = $class->new();
107 $clone->copy_arguments( $self );
108  
109 return $clone;
110 }
111  
112 1;
113