Use "parse_list_arg," put field order into field object, added "order"
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Schema / View.pm
1 package SQL::Translator::Schema::View;
2
3 # ----------------------------------------------------------------------
4 # $Id: View.pm,v 1.1 2003-05-01 04:25:00 kycl4rk Exp $
5 # ----------------------------------------------------------------------
6 # Copyright (C) 2003 Ken Y. Clark <kclark@cpan.org>
7 #
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; version 2.
11 #
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 # 02111-1307  USA
21 # -------------------------------------------------------------------
22
23 =pod
24
25 =head1 NAME
26
27 SQL::Translator::Schema::View - SQL::Translator view object
28
29 =head1 SYNOPSIS
30
31   use SQL::Translator::Schema::View;
32   my $view = SQL::Translator::Schema::View->new(
33       name => 'foo',
34       sql  => 'select * from foo',
35   );
36
37 =head1 DESCRIPTION
38
39 C<SQL::Translator::Schema::View> is the view object.
40
41 =head1 METHODS
42
43 =cut
44
45 use strict;
46 use Class::Base;
47
48 use base 'Class::Base';
49 use vars qw($VERSION $TABLE_COUNT $VIEW_COUNT);
50
51 $VERSION = 1.00;
52
53 # ----------------------------------------------------------------------
54 sub init {
55
56 =pod
57
58 =head2 new
59
60 Object constructor.
61
62   my $schema = SQL::Translator::Schema::View->new;
63
64 =cut
65
66     my ( $self, $config ) = @_;
67     $self->params( $config, qw[ name sql ] );
68     return $self;
69 }
70
71 # ----------------------------------------------------------------------
72 sub name {
73
74 =pod
75
76 =head2 name
77
78 Get or set the view's name.
79
80   my $name = $view->name('foo');
81
82 =cut
83
84     my $self        = shift;
85     $self->{'name'} = shift if @_;
86     return $self->{'name'} || '';
87 }
88
89 # ----------------------------------------------------------------------
90 sub sql {
91
92 =pod
93
94 =head2 sql
95
96 Get or set the view's SQL.
97
98   my $sql = $view->sql('select * from foo');
99
100 =cut
101
102     my $self       = shift;
103     $self->{'sql'} = shift if @_;
104     return $self->{'sql'} || '';
105 }
106
107 # ----------------------------------------------------------------------
108 sub is_valid {
109
110 =pod
111
112 =head2 is_valid
113
114 Determine whether the view is valid or not.
115
116   my $ok = $view->is_valid;
117
118 =cut
119
120     my $self = shift;
121     return 1 if $self->name && $self->sql;
122 }
123
124 1;
125
126 # ----------------------------------------------------------------------
127
128 =pod
129
130 =head1 AUTHOR
131
132 Ken Y. Clark E<lt>kclark@cpan.orgE<gt>
133
134 =cut