PGObject::Simple::Role(3pm)

PGObject::Simple::Role3pm

Moo/moose mappers for minimalist pgobject framework

Usage

Take the following (Moose) class:

    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 a stored procedure:

    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;
    $$;

Then the following 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');

The following will also work since you have the dbmethod call above:

    my $int = $foobar->int;

The full interface of call_dbmethod and call_procedure from PGObject::Simple are supported, and call_dbmethod is effectively wrapped by dbmethod(), allowing a declarative mapping.

Version

Version 2.0.2

Overview

Attributes and lazy getters

_get_registry

This is a method the consuming classes can override in order to set the registry of the calls for type mapping purposes.

_get_schema

Returns the default schema associated with the object.

_get_prefix

Returns string, default is an empty string, used to set a prefix for mapping stored prcedures to an object class.

Read only accessors (public)

dbh

Wraps the PGObject::Simple method

funcschema

Returns the schema bound to the object

funcprefix

Prefix for functions

Removed methods

These methods were once part of this package but have been removed due to the philosophy of not adding framework dependencies when an application dependency can work just as well.

dbmethod

Included in versions 0.50 - 0.71.

Instead of using this directly, use:

   use PGObject::Util::DBMethod;

instead. Ideally this should be done in your actual class since that will allow you to 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.

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

Releases

6 releases since Debian 8 (Jessie); the text changed 4 times.

  1. 8
  2. 9
  3. 10
  4. 11
  5. 12–13

Author

Chris Travers,, "<chris.travers at gmail.com>"

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

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.

From libpgobject-simple-role-perl 2.000002-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.