1 package Maypole::Model::CDBI::Plain;
3 use base 'Maypole::Model::CDBI';
6 Maypole::Config->mk_accessors(qw(table_to_class));
10 Maypole::Model::CDBI::Plain - Class::DBI model without ::Loader
15 use 'Maypole::Application';
17 Foo->config->model("Maypole::Model::CDBI::Plain");
18 Foo->setup([qw/ Foo::SomeTable Foo::Other::Table /]);
22 This module allows you to use Maypole with previously set-up
23 L<Class::DBI> classes; simply call C<setup> with a list reference
24 of the classes you're going to use, and Maypole will work out the
25 tables and set up the inheritance relationships as normal.
31 This method is inherited from Maypole::Model::Base and calls setup_database,
32 which uses Class::DBI::Loader to create and load Class::DBI classes from
33 the given database schema.
37 This method loads the model classes for the application
44 my ( $self, $config, $namespace, $classes ) = @_;
45 $config->{classes} = $classes;
46 foreach my $class (@$classes) { $namespace->load_model_subclass($class); }
47 $namespace->model_classes_loaded(1);
48 $config->{table_to_class} = { map { $_->table => $_ } @$classes };
49 $config->{tables} = [ keys %{ $config->{table_to_class} } ];
54 returns class for given table
59 my ( $self, $r, $table ) = @_;
60 return $r->config->{table_to_class}->{$table};
65 This class method is passed the name of a model class that represensts a table
66 and allows the master model class to do any set-up required.
71 my ( $self, $child ) = @_;
72 if ( my $col = $child->stringify_column ) {
73 $child->columns( Stringify => $col );
79 L<Maypole::Model::Base>
81 L<Maypole::Model::CDBI>