File Coverage

lib/DBIx/Schema/Changelog/Action.pm
Criterion Covered Total %
statement 19 19 100.0
branch 3 6 50.0
condition n/a
subroutine 6 6 100.0
pod n/a
total 28 31 90.3


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