| 1 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | |||||||||||||||
| 4 | package Footprintless::Plugin::Database; | ||||||||||||||
| 5 | 1 | $Footprintless::Plugin::Database::VERSION = '1.06'; | |||||||||||||
| 6 | # ABSTRACT: A Footprintless plugin for working with databases | ||||||||||||||
| 7 | # PODNAME: Footprintless::Plugin::Database | ||||||||||||||
| 8 | |||||||||||||||
| 9 | 1 | ▶ | use Footprintless::Util qw(dynamic_module_new); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | |||||||||||||||
| 11 | 1 | ▶ | use parent qw(Footprintless::Plugin); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | |||||||||||||||
| 13 | 8 | ▶ | sub db { | ||||||||||||
|
Subroutine
db: called CC=6 SCAR=18.5
Pod
documented
| |||||||||||||||
| 14 | 8 | my ( $self, $footprintless, $coordinate, @rest ) = @_; | |||||||||||||
| 15 | 8 | ▶ | die("database plugin config required") unless ( $self->{config} ); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 16 | |||||||||||||||
| 17 | 8 | my $entity = $footprintless->entities()->get_entity($coordinate); | |||||||||||||
| 18 | |||||||||||||||
| 19 | my $provider = | ||||||||||||||
| 20 | $entity->{provider} ? $self->{config}{providers}{ $entity->{provider} } | ||||||||||||||
| 21 | : $self->{config}{default_provider} | ||||||||||||||
| 22 | ? $self->{config}{providers}{ $self->{config}{default_provider} } | ||||||||||||||
| 23 | 8 | ▶ | : undef; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 24 | 8 | ▶ | if ($provider) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 25 | 7 | return dynamic_module_new( $provider, $footprintless, $coordinate, @rest ); | |||||||||||||
| 26 | } | ||||||||||||||
| 27 | else { | ||||||||||||||
| 28 | 1 | ▶ | if ( $entity->{provider} ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 29 | 1 | die("unsupported database provider: $entity->{provider}"); | |||||||||||||
| 30 | } | ||||||||||||||
| 31 | else { | ||||||||||||||
| 32 | 0 | die("provider not specified and no default configured"); | |||||||||||||
| 33 | } | ||||||||||||||
| 34 | } | ||||||||||||||
| 35 | } | ||||||||||||||
| 36 | |||||||||||||||
| 37 | 0 | ▶ | sub db_command_helper { | ||||||||||||
|
Subroutine
db_command_helper: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 38 | 0 | my ( $self, $footprintless, $coordinate, @rest ) = @_; | |||||||||||||
| 39 | return $self->{config}{command_helper} | ||||||||||||||
| 40 | ? dynamic_module_new( $self->{config}{command_helper} ) | ||||||||||||||
| 41 | 0 | ▶ | : dynamic_module_new('Footprintless::Plugin::Database::DefaultCommandHelper'); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 42 | } | ||||||||||||||
| 43 | |||||||||||||||
| 44 | 8 | ▶ | sub factory_methods { | ||||||||||||
|
Subroutine
factory_methods: called CC=1 SCAR=0.2
Pod
documented
| |||||||||||||||
| 45 | 8 | my ($self) = @_; | |||||||||||||
| 46 | return { | ||||||||||||||
| 47 | 8 | ▶ | db => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 48 | 8 | return $self->db(@_); | |||||||||||||
| 49 | }, | ||||||||||||||
| 50 | 0 | ▶ | db_command_helper => sub { | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 51 | 0 | return $self->db_command_helper(@_); | |||||||||||||
| 52 | } | ||||||||||||||
| 53 | 8 | }; | |||||||||||||
| 54 | } | ||||||||||||||
| 55 | |||||||||||||||
| 56 | 1 | 1; | |||||||||||||
| 57 | |||||||||||||||
| 58 | __END__ | ||||||||||||||