File Coverage

lib/DBIx/Schema/Changelog/Action/View.pm
Criterion Covered Total %
statement 24 24 100.0
branch 1 2 50.0
condition n/a
subroutine 7 7 100.0
pod 3 3 100.0
total 35 36 97.2


line stmt bran cond sub pod time code
1             package DBIx::Schema::Changelog::Action::View;
2              
3             =head1 NAME
4              
5             DBIx::Schema::Changelog::Action::View - Handles view actions
6              
7             =head1 VERSION
8              
9             Version 0.7.1
10              
11             =cut
12              
13             our $VERSION = '0.7.1';
14              
15 5     5   2164 use strict;
  5         8  
  5         215  
16 5     5   22 use warnings;
  5         8  
  5         148  
17 5     5   21 use Moose;
  5         8  
  5         39  
18              
19             with 'DBIx::Schema::Changelog::Action';
20              
21             =head1 SUBROUTINES/METHODS
22              
23             =over 4
24              
25             =item add
26              
27             Add view
28              
29             =cut
30              
31             sub add {
32 3     3 1 650 my ( $self, $params ) = @_;
33 3         156 my $actions = $self->driver()->actions;
34 3 50       14 die " Create view is not supported!" unless ( $actions->{create_view} );
35 3         23 my $sql = _replace_spare( $actions->{create_view},
36             [ $params->{name}, $params->{as} ] );
37 3         15 $self->_do($sql);
38             }
39              
40             =item alter
41              
42             Drop view and add new one.
43              
44             =cut
45              
46             sub alter {
47 1     1 1 4 my ( $self, $params ) = @_;
48 1         5 $self->drop($params);
49 1         15054 $self->add($params);
50             }
51              
52             =item drop
53              
54             Drop defined view.
55              
56             =cut
57              
58             sub drop {
59 2     2 1 5 my ( $self, $params ) = @_;
60 2         94 my $actions = $self->driver()->actions;
61 2         12 my $sql = _replace_spare( $actions->{drop_view}, [ $params->{name} ] );
62 2         8 $self->_do($sql);
63              
64             }
65              
66 5     5   27319 no Moose;
  5         10  
  5         27  
67             __PACKAGE__->meta->make_immutable;
68              
69             1;
70              
71             __END__
72              
73             =back
74              
75             =head1 AUTHOR
76              
77             Mario Zieschang, C<< <mario.zieschang at combase.de> >>
78              
79             =head1 LICENSE AND COPYRIGHT
80              
81             Copyright 2015 Mario Zieschang.
82              
83             This program is free software; you can redistribute it and/or modify it
84             under the terms of the the Artistic License (2.0). You may obtain a
85             copy of the full license at:
86              
87             L<http://www.perlfoundation.org/artistic_license_2_0>
88              
89             Any use, modification, and distribution of the Standard or Modified
90             Versions is governed by this Artistic License. By using, modifying or
91             distributing the Package, you accept this license. Do not use, modify,
92             or distribute the Package, if you do not accept this license.
93              
94             If your Modified Version has been derived from a Modified Version made
95             by someone other than you, you are nevertheless required to ensure that
96             your Modified Version complies with the requirements of this license.
97              
98             This license does not grant you the right to use any trademark, service
99             mark, trade name, or logo of the Copyright Holder.
100              
101             This license includes the non-exclusive, worldwide, free-of-charge
102             patent license to make, have made, use, offer to sell, sell, import and
103             otherwise transfer the Package with respect to any patent claims
104             licensable by the Copyright Holder that are necessarily infringed by the
105             Package. If you institute patent litigation (including a cross-claim or
106             counterclaim) against any party alleging that the Package constitutes
107             direct or contributory patent infringement, then this Artistic License
108             to you shall terminate on the date that such litigation is filed.
109              
110             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
111             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
112             THE IMPLIED WARRANTIES OF MERCHANT ABILITY, FITNESS FOR A PARTICULAR
113             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
114             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
115             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
116             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
117             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
118              
119             =cut