File Coverage

lib/DBIx/Schema/Changelog/Action.pm
Criterion Covered Total %
statement 22 22 100.0
branch 3 6 50.0
condition n/a
subroutine 7 7 100.0
pod n/a
total 32 35 91.4


line stmt bran cond sub pod time code
1             package DBIx::Schema::Changelog::Action;
2              
3             =head1 NAME
4              
5             DBIx::Schema::Changelog::Action - Abstract action class.
6              
7             =head1 VERSION
8              
9             Version 0.8.0
10              
11             =cut
12              
13             our $VERSION = '0.8.0';
14              
15 14     14   11778 use utf8;
  14         41  
  14         204  
16 14     14   579 use strict;
  14         24  
  14         689  
17 14     14   109 use warnings FATAL => 'all';
  14         24  
  14         783  
18 14     14   1737 use Moose::Role;
  14         587471  
  14         119  
19 14     14   97704 use Data::Dumper;
  14         57160  
  14         5412  
20              
21             =head1 ATTRIBUTES
22              
23             =head2 driver
24              
25             Loaded DBIx::Schema::Changelog::Driver module.
26              
27             =cut
28              
29             has driver => ( is => 'ro', );
30              
31             =head2 driver
32              
33             Connected dbh object.
34              
35             =cut
36              
37             has dbh => ( is => 'ro', );
38              
39             =head1 SUBROUTINES/METHODS
40              
41             =head2 add
42              
43             Required sub to run add for specific action type.
44              
45             =cut
46              
47             requires 'add';
48              
49             =head2 alter
50              
51             Required sub to run alter for specific action type.
52              
53             =cut
54              
55             requires 'alter';
56              
57             =head2 drop
58              
59             Required sub to run drop for specific action type.
60              
61             =cut
62              
63             requires 'drop';
64              
65             =head1 SUBROUTINES/METHODS (private)
66              
67             =head2 _replace_spare
68              
69             Replace spares which comes from DBIx::Schema::Changelog::Driver module.
70              
71             =cut
72              
73             sub _replace_spare {
74 54     54   131 my ( $string, $options, $debug ) = @_;
75 54 50       160 print Dumper( $string, $options ) if ($debug);
76 54         860 $string =~ s/\{(\d+)\}/$options->[$1]/g;
77 54 50       171 print Dumper($string) if ($debug);
78 54         273 return $string;
79             }
80              
81             =head2 _do
82              
83             Running generated sql statements.
84              
85             =cut
86              
87             sub _do {
88 25     25   59 my ( $self, $sql ) = @_;
89 25 50       1230 $self->dbh()->do($sql) or die "Can't handle sql: \n\t$sql\n $!";
90             }
91              
92             1; # End of DBIx::Schema::Changelog::Action
93              
94             __END__
95              
96             =head1 AUTHOR
97              
98             Mario Zieschang, C<< <mario.zieschang at combase.de> >>
99              
100             =head1 LICENSE AND COPYRIGHT
101              
102             Copyright 2015 Mario Zieschang.
103              
104             This program is free software; you can redistribute it and/or modify it
105             under the terms of the the Artistic License (2.0). You may obtain a
106             copy of the full license at:
107              
108             L<http://www.perlfoundation.org/artistic_license_2_0>
109              
110             Any use, modification, and distribution of the Standard or Modified
111             Versions is governed by this Artistic License. By using, modifying or
112             distributing the Package, you accept this license. Do not use, modify,
113             or distribute the Package, if you do not accept this license.
114              
115             If your Modified Version has been derived from a Modified Version made
116             by someone other than you, you are nevertheless required to ensure that
117             your Modified Version complies with the requirements of this license.
118              
119             This license does not grant you the right to use any trademark, service
120             mark, trade name, or logo of the Copyright Holder.
121              
122             This license includes the non-exclusive, worldwide, free-of-charge
123             patent license to make, have made, use, offer to sell, sell, import and
124             otherwise transfer the Package with respect to any patent claims
125             licensable by the Copyright Holder that are necessarily infringed by the
126             Package. If you institute patent litigation (including a cross-claim or
127             counterclaim) against any party alleging that the Package constitutes
128             direct or contributory patent infringement, then this Artistic License
129             to you shall terminate on the date that such litigation is filed.
130              
131             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
132             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
133             THE IMPLIED WARRANTIES OF MERCHANT ABILITY, FITNESS FOR A PARTICULAR
134             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
135             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
136             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
137             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
138             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
139              
140              
141             =cut
142