line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geoffrey::Role::Action; |
2
|
|
|
|
|
|
|
|
3
|
20
|
|
|
20
|
|
129904
|
use utf8; |
|
20
|
|
|
|
|
70
|
|
|
20
|
|
|
|
|
99
|
|
4
|
20
|
|
|
20
|
|
581
|
use strict; |
|
20
|
|
|
|
|
44
|
|
|
20
|
|
|
|
|
436
|
|
5
|
20
|
|
|
20
|
|
122
|
use warnings FATAL => 'all'; |
|
20
|
|
|
|
|
39
|
|
|
20
|
|
|
|
|
14822
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$Geoffrey::Role::Action::VERSION = '0.000203'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
184
|
|
|
184
|
1
|
3128
|
my $class = shift; |
11
|
184
|
|
|
|
|
564
|
my $self = {@_}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# make converter required |
14
|
184
|
100
|
|
|
|
605
|
if ( !$self->{converter} ) { |
15
|
1
|
|
|
|
|
7
|
require Geoffrey::Exception::RequiredValue; |
16
|
1
|
|
|
|
|
6
|
Geoffrey::Exception::RequiredValue::throw_converter( __PACKAGE__ . '::new' ); |
17
|
|
|
|
|
|
|
} |
18
|
183
|
|
|
|
|
833
|
return bless $self, $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
190
|
|
|
190
|
1
|
1146
|
sub dbh { return $_[0]->{dbh} } |
22
|
|
|
|
|
|
|
|
23
|
575
|
|
|
575
|
1
|
3130
|
sub converter { return $_[0]->{converter} } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub add { |
26
|
1
|
|
|
1
|
1
|
57
|
require Geoffrey::Exception::NotSupportedException; |
27
|
1
|
|
|
|
|
6
|
return Geoffrey::Exception::NotSupportedException::throw_action( 'add', shift ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub alter { |
31
|
9
|
|
|
9
|
1
|
5623
|
require Geoffrey::Exception::NotSupportedException; |
32
|
9
|
|
|
|
|
41
|
return Geoffrey::Exception::NotSupportedException::throw_action( 'alter', shift ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub drop { |
36
|
4
|
|
|
4
|
1
|
3292
|
require Geoffrey::Exception::NotSupportedException; |
37
|
4
|
|
|
|
|
19
|
return Geoffrey::Exception::NotSupportedException::throw_action( 'drop', shift ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub list_from_schema { |
41
|
2
|
|
|
2
|
1
|
1581
|
require Geoffrey::Exception::NotSupportedException; |
42
|
2
|
|
|
|
|
9
|
return Geoffrey::Exception::NotSupportedException::throw_action( 'list_from_schema', shift ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub dryrun { |
46
|
127
|
|
|
127
|
1
|
5562
|
my ( $self, $dryrun ) = @_; |
47
|
127
|
100
|
|
|
|
643
|
return $self->{dryrun} if !defined $dryrun; |
48
|
44
|
|
|
|
|
119
|
$self->{dryrun} = $dryrun; |
49
|
44
|
|
|
|
|
171
|
return $self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub for_table { |
53
|
434
|
|
|
434
|
1
|
870
|
my ( $self, $for_table ) = @_; |
54
|
434
|
100
|
|
|
|
1086
|
return $self->{for_table} if !defined $for_table; |
55
|
323
|
|
|
|
|
466
|
$self->{for_table} = $for_table; |
56
|
323
|
|
|
|
|
707
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub do { |
60
|
45
|
|
|
45
|
1
|
130
|
my ( $self, $s_sql ) = @_; |
61
|
45
|
100
|
|
|
|
173
|
return $s_sql if $self->dryrun; |
62
|
30
|
|
|
|
|
5099
|
require Geoffrey::Exception::Database; |
63
|
30
|
100
|
|
|
|
187
|
Geoffrey::Exception::Database::throw_no_dbh() if !$self->dbh; |
64
|
29
|
100
|
|
|
|
80
|
$self->dbh->do($s_sql) or Geoffrey::Exception::Database::throw_sql_handle( $!, $s_sql ); |
65
|
26
|
|
|
|
|
379207
|
return $s_sql; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub do_arrayref { |
69
|
17
|
|
|
17
|
1
|
574
|
my ( $self, $s_sql, $options ) = @_; |
70
|
17
|
50
|
|
|
|
49
|
return unless $s_sql; |
71
|
17
|
100
|
|
|
|
65
|
return [] if $self->dryrun; |
72
|
14
|
|
|
|
|
1451
|
require Geoffrey::Exception::Database; |
73
|
14
|
50
|
|
|
|
80
|
Geoffrey::Exception::Database::throw_no_dbh() if !$self->dbh; |
74
|
14
|
|
66
|
|
|
66
|
return $self->dbh->selectall_arrayref( $s_sql, { Slice => {} }, @{$options} ) |
75
|
|
|
|
|
|
|
|| Geoffrey::Exception::Database::throw_sql_handle( $!, $s_sql ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub do_prepared { |
79
|
9
|
|
|
9
|
1
|
30
|
my ( $self, $s_sql, $ar_values ) = @_; |
80
|
9
|
100
|
|
|
|
31
|
return $s_sql if $self->dryrun; |
81
|
8
|
|
|
|
|
47
|
require Carp; |
82
|
8
|
50
|
|
|
|
35
|
my $obj_prepared_statement = $self->dbh->prepare($s_sql) or Carp::longmess( $!, $s_sql ); |
83
|
8
|
50
|
|
|
|
1146
|
$obj_prepared_statement->execute( @{$ar_values} ) or Carp::longmess( $!, $s_sql ); |
|
8
|
|
|
|
|
75855
|
|
84
|
8
|
|
|
|
|
363
|
return $s_sql; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; # End of Geoffrey::Role::Action |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |