| 1 | package Geoffrey::Role::Action; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 20 | ▶ | use utf8; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 20 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 20 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 20 | $Geoffrey::Role::Action::VERSION = '0.000206'; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 184 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 10 | 184 | my $class = shift; | |||||||||||||||||||
| 11 | 184 | my $self = {@_}; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | # make converter required | ||||||||||||||||||||
| 14 | 184 | ▶ | if ( !$self->{converter} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 15 | 1 | require Geoffrey::Exception::RequiredValue; | |||||||||||||||||||
| 16 | 1 | Geoffrey::Exception::RequiredValue::throw_converter( __PACKAGE__ . '::new' ); | |||||||||||||||||||
| 17 | } | ||||||||||||||||||||
| 18 | 183 | return bless $self, $class; | |||||||||||||||||||
| 19 | } | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 198 | ▶ | sub dbh { return $_[0]->{dbh} } | ||||||||||||||||||
|
Subroutine
dbh: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 575 | ▶ | sub converter { return $_[0]->{converter} } | ||||||||||||||||||
|
Subroutine
converter: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 1 | ▶ | sub add { | ||||||||||||||||||
|
Subroutine
add: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 26 | 1 | require Geoffrey::Exception::NotSupportedException; | |||||||||||||||||||
| 27 | 1 | return Geoffrey::Exception::NotSupportedException::throw_action( 'add', shift ); | |||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 9 | ▶ | sub alter { | ||||||||||||||||||
|
Subroutine
alter: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 31 | 9 | require Geoffrey::Exception::NotSupportedException; | |||||||||||||||||||
| 32 | 9 | return Geoffrey::Exception::NotSupportedException::throw_action( 'alter', shift ); | |||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 4 | ▶ | sub drop { | ||||||||||||||||||
|
Subroutine
drop: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 36 | 4 | require Geoffrey::Exception::NotSupportedException; | |||||||||||||||||||
| 37 | 4 | return Geoffrey::Exception::NotSupportedException::throw_action( 'drop', shift ); | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 2 | ▶ | sub list_from_schema { | ||||||||||||||||||
|
Subroutine
list_from_schema: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 41 | 2 | require Geoffrey::Exception::NotSupportedException; | |||||||||||||||||||
| 42 | 2 | return Geoffrey::Exception::NotSupportedException::throw_action( 'list_from_schema', shift ); | |||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 127 | ▶ | sub dryrun { | ||||||||||||||||||
|
Subroutine
dryrun: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 46 | 127 | my ( $self, $dryrun ) = @_; | |||||||||||||||||||
| 47 | 127 | ▶ | return $self->{dryrun} if !defined $dryrun; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 48 | 44 | $self->{dryrun} = $dryrun; | |||||||||||||||||||
| 49 | 44 | return $self; | |||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 434 | ▶ | sub for_table { | ||||||||||||||||||
|
Subroutine
for_table: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 53 | 434 | my ( $self, $for_table ) = @_; | |||||||||||||||||||
| 54 | 434 | ▶ | return $self->{for_table} if !defined $for_table; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 55 | 323 | $self->{for_table} = $for_table; | |||||||||||||||||||
| 56 | 323 | return $self; | |||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 45 | ▶ | sub do { | ||||||||||||||||||
|
Subroutine
do: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||
| 60 | 45 | my ( $self, $s_sql ) = @_; | |||||||||||||||||||
| 61 | 45 | ▶ | return $s_sql if $self->dryrun; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 62 | 30 | require Geoffrey::Exception::Database; | |||||||||||||||||||
| 63 | 30 | ▶ | Geoffrey::Exception::Database::throw_no_dbh() if !$self->dbh; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 64 | 29 | ▶ | $self->dbh->do($s_sql) || Geoffrey::Exception::Database::throw_sql_handle( $self->dbh->errstr . "\n" . $self->dbh->err . "\n" . $!, $s_sql ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 65 | 26 | return $s_sql; | |||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 17 | ▶ | sub do_arrayref { | ||||||||||||||||||
|
Subroutine
do_arrayref: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||
| 69 | 17 | my ( $self, $s_sql, $options ) = @_; | |||||||||||||||||||
| 70 | 17 | ▶ | return unless $s_sql; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 71 | 17 | ▶ | return [] if $self->dryrun; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 72 | 14 | require Geoffrey::Exception::Database; | |||||||||||||||||||
| 73 | 14 | ▶ | Geoffrey::Exception::Database::throw_no_dbh() if !$self->dbh; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 74 | 14 | ▶ | return $self->dbh->selectall_arrayref( $s_sql, { Slice => {} }, @{$options} ) | ||||||||||||||||||
|
Condition66%2/3
$self->dbh->selectall_arrayref($s_sql, {'Slice', {}}, @{$options;}) || Geoffrey::Exception::Database::throw_sql_handle($self->dbh->errstr . "\n" . $self->dbh->err . "\n" . $!, $s_sql)
MC/DC0%0/2
$self->dbh->selectall_arrayref($s_sql, {'Slice', {}}, @{$options;}) || Geoffrey::Exception::Database::throw_sql_handle($self->dbh->errstr . "\n" . $self->dbh->err . "\n" . $!, $s_sql)
$self->dbh->selectall_arrayref($s_sql, {'Slice', {}}, @{$options;})
Geoffrey::Exception::Database::throw_sql_handle($self->dbh->errstr . "\n" . $self->dbh->err . "\n" . $!, $s_sql)
Truth table33%1/3
A || B
A= $self->dbh->selectall_arrayref($s_sql, {'Slice', {}}, @{$options;})B= Geoffrey::Exception::Database::throw_sql_handle($self->dbh->errstr . "\n" . $self->dbh->err . "\n" . $!, $s_sql)
| |||||||||||||||||||||
| 75 | || Geoffrey::Exception::Database::throw_sql_handle( $self->dbh->errstr . "\n" . $self->dbh->err . "\n" . $!, $s_sql ); | ||||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | 9 | ▶ | sub do_prepared { | ||||||||||||||||||
|
Subroutine
do_prepared: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||
| 79 | 9 | my ( $self, $s_sql, $ar_values ) = @_; | |||||||||||||||||||
| 80 | 9 | ▶ | return $s_sql if $self->dryrun; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 81 | 8 | require Carp; | |||||||||||||||||||
| 82 | 8 | ▶ | my $obj_prepared_statement = $self->dbh->prepare($s_sql) or Carp::longmess( $!, $s_sql ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 83 | 8 | ▶ | $obj_prepared_statement->execute( @{$ar_values} ) or Carp::longmess( $!, $s_sql ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 84 | 8 | return $s_sql; | |||||||||||||||||||
| 85 | } | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | 20 | 1; # End of Geoffrey::Role::Action | |||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | __END__ | ||||||||||||||||||||