PGObje...::Role(3pm)
π PGObje...::Role π
okay bestie, so this is the manual page for PGObje...::Role, and yes the name is literally abbreviated like that because it lives in section 3pm of the User Contributed Perl Documentation. We're talking Moo/Moose mappers for the minimalist PGObject framework, and I'm gonna walk you through it like we're texting at 2am. π¦
β¨ NAME β¨
PGObject::Simple::Role β Moo/Moose mappers for minimalist PGObject framework. that's it, that's the whole vibe. π
πΈ VERSION πΈ
Version 2.0.2, no cap.
π§ SYNOPSIS π§
ok so picture this (Moose) class, right:
package MyAPP::Foo;
use PGObject::Util::DBMethod;
use Moose;
with 'PGObject::Simple::Role';
has id => (is => 'ro', isa => 'Int', required => 0);
has foo => (is => 'ro', isa => 'Str', required => 0);
has bar => (is => 'ro', isa => 'Str', required => 0);
has baz => (is => 'ro', isa => 'Int', required => 0);
sub get_dbh {
return DBI->connect('dbi:Pg:dbname=foobar');
}
# PGObject::Util::DBMethod exports this
dbmethod int => (funcname => 'foo_to_int');
and then a stored procedure, because obviously:
CREATE OR REPLACE FUNCTION foo_to_int
(in_id int, in_foo text, in_bar text, in_baz int)
RETURNS INT LANGUAGE SQL AS
$$
select char_length($2) + char_length($3) + $1 * $4;
$$;
with all that in place, this Perl code would work to invoke it:
my $foobar = MyApp->foo(id => 3, foo => 'foo', bar => 'baz', baz => 33);
$foobar->call_dbmethod(funcname => 'foo_to_int');
and this also works, because you've got that dbmethod call up there:
my $int = $foobar->int;
and here's the tea: the full interface of call_dbmethod and call_procedure from PGObject::Simple is supported, and call_dbmethod is effectively wrapped by dbmethod(), which is what lets you do that declarative mapping thing. iconic behavior honestly. π
π DESCRIPTION π
π ATTRIBUTES AND LAZY GETTERS π
_get_registry
this is a method the consuming classes can override so they can set the registry of the calls for type mapping purposes. yes, override it, it's yours. π«Ά
_get_schema
returns the default schema associated with the object.
_get_prefix
returns a string, and the default is an empty string. it's used to set a prefix for mapping stored prcedures to an object class.
ngl, "prcedures" is spelled like that in the original and I'm keeping it, we don't erase history here. π
π READ ONLY ACCESSORS (PUBLIC) π
dbh
wraps the PGObject::Simple method.
funcschema
returns the schema bound to the object.
funcprefix
prefix for functions.
π REMOVED METHODS π
ok so these methods were once part of this package but they got removed, and the reason is the philosophy of not adding framework dependencies when an application dependency can work just as well. respect the decision honestly.
dbmethod
included in versions 0.50 β 0.71.
instead of using this directly, use:
use PGObject::Util::DBMethod;
instead. ideally you should do this in your actual class, because that lets you dispense with the extra parentheses. however, if you need a backwards-compatible and central solution β since PGObject::Simple::Role generally assumes sub-roles will be created for managing db connections etc. β you can put the use statement there and it will have the same impact as it did here when it was removed, with the benefit of better testing. slay. β¨
π AUTHOR π
Chris Travers,, "<chris.travers at gmail.com>"
(yes, two commas, it's giving mystery, I'm not touching it π΅οΈβοΈ)
π BUGS π
Please report any bugs or feature requests to "bug-pgobject-simple-role at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PGObject-Simple-Role>. I will be notified, and then you'll Chris Travers,, "<chris.travers at gmail.com>"
π BUGS π
ok yeah there are literally two BUGS sections, the first one trails off mid-sentence and I refuse to edit it because the rule is keep every detail. anyway:
Please report any bugs or feature requests to "bug-pgobject-simple-role at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PGObject-Simple-Role>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. πβ¨
π SUPPORT π
You can find documentation for this module with the perldoc command.
perldoc PGObject::Simple::Role
You can also look for information at:
- RT: CPAN's request tracker (report bugs here)
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=PGObject-Simple-Role>
- AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/PGObject-Simple-Role>
- CPAN Ratings
<http://cpanratings.perl.org/d/PGObject-Simple-Role>
- Search CPAN
<http://search.cpan.org/dist/PGObject-Simple-Role/>
π ACKNOWLEDGEMENTS π
...yeah this section is empty in the original. nothing here. a moment of silence for the acknowledgements that never came. π
π LICENSE AND COPYRIGHT π
Copyright 2013-2017 Chris Travers,.
Redistribution and use in source and compiled forms with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer as the first lines of this file unmodified.
- Redistributions in compiled form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the source code, documentation, and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
and that's the whole page bestie π₯° this was perl v5.34.0, dated 2022-06-16, and it's PGObje...::Role(3pm) forever and always. go forth and map your objects. periodt. πππ¦
π¦ where this page comes from
- debian bookworm: libpgobject-simple-role-perl 2.000002-2 Β· BSD-2-Clause
- debian trixie: libpgobject-simple-role-perl 2.000002-2 Β· BSD-2-Clause
- ubuntu noble: libpgobject-simple-role-perl 2.000002-2 Β· BSD-2-Clause
- ubuntu resolute: libpgobject-simple-role-perl 2.000002-2 Β· BSD-2-Clause
- ubuntu stonking: libpgobject-simple-role-perl 2.000002-2 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms