| 1 | package AutoSQL::Schema; | ||
| 2 | use strict; | ||
| 3 | use vars qw(@ISA); | ||
| 4 | use AutoCode::Schema; | ||
| 5 | our @ISA=qw(AutoCode::Schema); | ||
| 6 | use AutoSQL::TableModel; | ||
| 7 | |||
| 8 | use AutoCode::AccessorMaker('$'=>[qw(tables module_table_map)]); | ||
| 9 | |||
| 10 | sub _initialize { | ||
| 11 | my ($self, @args)=@_; | ||
| 12 | $self->SUPER::_initialize(@args); | ||
| 13 | |||
| 14 | my ($tables, $module_table_map)= | ||
| 15 | $self->_rearrange( [qw(TABLES MODULE_TABLE_MAP )], @args); | ||
| 16 | |||
| 17 | $self->tables($tables); | ||
| 18 | $self->module_table_map($module_table_map); | ||
| 19 | } | ||
| 20 | |||
| 21 | # This method is to be replaced with $module_table map in schema. | ||
| 22 | our %TABLE_MODELS; | ||
| 23 | sub get_table_model { | ||
| 24 | my ($self, $type)=@_; | ||
| 25 | return $TABLE_MODELS{$type} if exists $TABLE_MODELS{$type}; | ||
| 26 | my $model = AutoSQL::TableModel->new( | ||
| 27 | -schema => $self, | ||
| 28 | -type => $type | ||
| 29 | ); | ||
| 30 | $TABLE_MODELS{$type}=$model; | ||
| 31 | return $model; | ||
| 32 | } | ||
| 33 | |||
| 34 | 1; |