| … | |
… | |
| 24 | |
24 | |
| 25 | sub new($$) { |
25 | sub new($$) { |
| 26 | my ($invocant, $ce) = @_; |
26 | my ($invocant, $ce) = @_; |
| 27 | my $class = ref($invocant) || $invocant; |
27 | my $class = ref($invocant) || $invocant; |
| 28 | my $self = {}; |
28 | my $self = {}; |
|
|
29 | bless $self, $class; # bless this here so we can pass it to the schema |
| 29 | |
30 | |
| 30 | # load the modules required to handle each table, and create driver |
31 | # load the modules required to handle each table, and create driver |
| 31 | foreach my $table (TABLES) { |
32 | foreach my $table (TABLES) { |
| 32 | unless (defined $ce->{dbLayout}->{$table}) { |
33 | unless (defined $ce->{dbLayout}->{$table}) { |
| 33 | #warn "ignoring table $table: layout not specified in dbLayout"; # *** |
34 | warn "ignoring table $table: layout not specified in dbLayout"; # *** |
| 34 | next; |
35 | next; |
| 35 | } |
36 | } |
| 36 | |
37 | |
| 37 | my $layout = $ce->{dbLayout}->{$table}; |
38 | my $layout = $ce->{dbLayout}->{$table}; |
| 38 | my $record = $layout->{record}; |
39 | my $record = $layout->{record}; |
| … | |
… | |
| 42 | my $params = $layout->{params}; |
43 | my $params = $layout->{params}; |
| 43 | |
44 | |
| 44 | runtime_use($record); |
45 | runtime_use($record); |
| 45 | runtime_use($schema); |
46 | runtime_use($schema); |
| 46 | runtime_use($driver); |
47 | runtime_use($driver); |
| 47 | $self->{$table} = $schema->new($driver->new($source, $params), $table, $record, $params); |
48 | $self->{$table} = $schema->new( |
|
|
49 | $self, |
|
|
50 | $driver->new($source, $params), |
|
|
51 | $table, |
|
|
52 | $record, |
|
|
53 | $params |
|
|
54 | ); |
| 48 | } |
55 | } |
| 49 | |
56 | |
| 50 | bless $self, $class; |
|
|
| 51 | return $self; |
57 | return $self; |
| 52 | } |
58 | } |
| 53 | |
59 | |
| 54 | ################################################################################ |
60 | ################################################################################ |
| 55 | # password functions |
61 | # password functions |