| 1 | package PGObject::Composite::Role; | ||
| 2 | |||
| 3 | 3 | ▶ | use 5.010; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 3 | ▶ | use warnings FATAL => 'all'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 3 | ▶ | use Moo::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 3 | ▶ | use PGObject::Composite ':all'; |
|
Subroutine
BEGIN: called CC=1 SCAR=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 1 | ||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | 3 | 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 | 3 | has _dbh => (is => 'lazy'); | |
| 52 | |||
| 53 | 0 | ▶ | sub _build__dbh { |
|
Subroutine
_build__dbh: not called CC=1 SCAR=6.9
| |||
| 54 | 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 | 3 | 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 | 3 | 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 | 3 | 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<< <chris at efficito.com> >> | ||
| 115 | |||
| 116 | =head1 BUGS | ||
| 117 | |||
| 118 | Please report any bugs or feature requests to C<bug-pgobject-composite-role at rt.cpan.org>, or through | ||
| 119 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PGObject-Composite-Role>. 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<http://rt.cpan.org/NoAuth/Bugs.html?Dist=PGObject-Composite-Role> | ||
| 139 | |||
| 140 | =item * AnnoCPAN: Annotated CPAN documentation | ||
| 141 | |||
| 142 | L<http://annocpan.org/dist/PGObject-Composite-Role> | ||
| 143 | |||
| 144 | =item * CPAN Ratings | ||
| 145 | |||
| 146 | L<http://cpanratings.perl.org/d/PGObject-Composite-Role> | ||
| 147 | |||
| 148 | =item * Search CPAN | ||
| 149 | |||
| 150 | L<http://search.cpan.org/dist/PGObject-Composite-Role/> | ||
| 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<http://www.opensource.org/licenses/BSD-3-Clause> | ||
| 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 | 3 | 1; # End of PGObject::Composite::Role | |