File Coverage

blib/lib/PGObject/Composite/Role.pm
Criterion Covered Total %
statement 14 16 87.5
branch n/a
condition n/a
subroutine 5 6 83.3
pod n/a
total 19 22 86.3


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