line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PGObject::Composite::Role; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
21380
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
54
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
44
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
838
|
use Moo::Role; |
|
1
|
|
|
|
|
28271
|
|
|
1
|
|
|
|
|
8
|
|
8
|
1
|
|
|
1
|
|
876
|
use PGObject::Composite; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
PGObject::Composite::Role - A Moo role interface for PGObject::Composite |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 0.02 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
A simple package with mapped stored procs: |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
package myobj; |
28
|
|
|
|
|
|
|
use Moo; |
29
|
|
|
|
|
|
|
with 'PGObject::Composite::Role'; |
30
|
|
|
|
|
|
|
use PGObject::Type::Composite; |
31
|
|
|
|
|
|
|
use PGObject::Util::DBMethod; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _get_dbh { DBI->connect(...); } |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has foo (is => 'ro'); |
36
|
|
|
|
|
|
|
has bar (is => 'ro'); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
dbmethod save => (funcname => 'save', returns_objects => 1); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 Properties and Builders |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 _dbh |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
This is the DBD::Pg database handle. Must be overridden. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Built by _get_dbh which application classes should override either directly or |
47
|
|
|
|
|
|
|
through an intermediate role. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has _dbh => (is => 'lazy', builder => '_get_dbh'); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _get_dbh { |
54
|
|
|
|
|
|
|
die 'Must overload get_dbh!'; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 _funcschema |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This is the default function schema. Default is 'public' |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has _funcschema => (is => 'lazy', builder => '_get_funcschema'); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _get_funcschema { 'public' } |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 _typeschema |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This is the schema under which the type is found. Defaults to public |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Builer is _get_schema |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
has _typeschema => (is => 'lazy', builder => '_get_schema'); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _get_schema { 'public' }; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 _typename |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Name of the type. This should be overridden by subclasses directly. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
The builder is _get_typename |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
has _typename => (is => 'lazy', builder => '_get_typename'); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _get_typename { die 'Must override _get_typename' }; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 METHODS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 call_procedure |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Calls a stored procedure with set properties from the object (dbh, etc). |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Must provide the following arguments: |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item funcname |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Name of function |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item args |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
arrayref of argument values |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=back |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub call_procedure { |
114
|
|
|
|
|
|
|
my @rows = PGObject::Composite::call_procedure(@_); |
115
|
|
|
|
|
|
|
return @rows if wantarray; |
116
|
|
|
|
|
|
|
return shift @rows; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 call_dbmethod |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Calls a mapped method by arguments. Handles things as per PGObject::Composite |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub call_dbmethod { |
126
|
|
|
|
|
|
|
my @rows = PGObject::Composite::call_dbmethod(@_); |
127
|
|
|
|
|
|
|
return @rows if wantarray; |
128
|
|
|
|
|
|
|
return shift @rows; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 AUTHOR |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Chris Travers, C<< >> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 BUGS |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
138
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
139
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 SUPPORT |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
perldoc PGObject::Composite::Role |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
You can also look for information at: |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=over 4 |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
L |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
L |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item * CPAN Ratings |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
L |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item * Search CPAN |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
L |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=back |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Copyright 2014 Chris Travers. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This program is distributed under the (Revised) BSD License: |
182
|
|
|
|
|
|
|
L |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without |
185
|
|
|
|
|
|
|
modification, are permitted provided that the following conditions |
186
|
|
|
|
|
|
|
are met: |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright |
189
|
|
|
|
|
|
|
notice, this list of conditions and the following disclaimer. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above copyright |
192
|
|
|
|
|
|
|
notice, this list of conditions and the following disclaimer in the |
193
|
|
|
|
|
|
|
documentation and/or other materials provided with the distribution. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
* Neither the name of Chris Travers's Organization |
196
|
|
|
|
|
|
|
nor the names of its contributors may be used to endorse or promote |
197
|
|
|
|
|
|
|
products derived from this software without specific prior written |
198
|
|
|
|
|
|
|
permission. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
201
|
|
|
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
202
|
|
|
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
203
|
|
|
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
204
|
|
|
|
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
205
|
|
|
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
206
|
|
|
|
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
207
|
|
|
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
208
|
|
|
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
209
|
|
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
210
|
|
|
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=cut |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
1; # End of PGObject::Composite::Role |