| 1 | package DBIO::PostgreSQL::PostGIS::Topology::Extension; | ||||||||||||||||||||
| 2 | # ABSTRACT: The postgis_topology extension: its topologies are runtime schemas, not the application's | ||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 4 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 4 | our $VERSION = '0.900007'; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 4 | ▶ | use base 'DBIO::Extension'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 6 | ▶ | sub extension_interface { 1 } | ||||||||||||||||||
|
Subroutine
extension_interface: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 9 | ▶ | sub name { 'postgis_topology' } | ||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 1 | ▶ | sub driver { 'DBIO::PostgreSQL' } | ||||||||||||||||||
|
Subroutine
driver: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 35 | ▶ | sub inspect { | ||||||||||||||||||
|
Subroutine
inspect: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||
| 20 | 35 | my ($class, $ctx) = @_; | |||||||||||||||||||
| 21 | 35 | ▶ | my $dbh = $ctx->{dbh} or return undef; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 34 | ▶ | my $schema = ($ctx->{self} // {})->{schema}; | ||||||||||||||||||
|
Condition50%1/2
$ctx->{"self"} // {}
MC/DC0%0/1
$ctx->{"self"} // {}
$ctx->{"self"}
Truth table50%1/2
A
A= $ctx->{"self"}
| |||||||||||||||||||||
| 24 | 34 | ▶ | $schema = 'topology' unless defined $schema; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 25 | 34 | my $table = $dbh->quote_identifier($schema) . '.' . $dbh->quote_identifier('topology'); | |||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 34 | my ($found) = $dbh->selectrow_array('SELECT to_regclass(?)', undef, $table); | |||||||||||||||||||
| 28 | 34 | ▶ | return undef unless defined $found; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 33 | my $rows = $dbh->selectall_arrayref( | |||||||||||||||||||
| 31 | "SELECT name, srid FROM $table ORDER BY name" | ||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||
| 33 | 33 | return { topologies => [ map { { name => $_->[0], srid => $_->[1] } } @$rows ] }; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 66 | ▶ | sub claims { | ||||||||||||||||||
|
Subroutine
claims: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||
| 38 | 66 | my ($class, $model, $ctx) = @_; | |||||||||||||||||||
| 39 | 66 | ▶ | my $state = ($ctx->{self} // {})->{state} or return []; | ||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$ctx->{"self"} // {}
MC/DC100%1/1
$ctx->{"self"} // {}
$ctx->{"self"}
Truth table100%2/2
A
A= $ctx->{"self"}
| |||||||||||||||||||||
| 40 | 64 | ▶ | return [ map { [ schema => $_->{name} ] } @{ $state->{topologies} // [] } ]; | ||||||||||||||||||
|
Condition50%1/2
$state->{"topologies"} // []
MC/DC0%0/1
$state->{"topologies"} // []
$state->{"topologies"}
Truth table50%1/2
A
A= $state->{"topologies"}
| |||||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 4 | 1; | |||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | __END__ | ||||||||||||||||||||