]> git.decadent.org.uk Git - maypole.git/commitdiff
Has no docs yet, but still useful.
authorSimon Cozens <simon@simon-cozens.org>
Mon, 14 Jun 2004 14:56:49 +0000 (14:56 +0000)
committerSimon Cozens <simon@simon-cozens.org>
Mon, 14 Jun 2004 14:56:49 +0000 (14:56 +0000)
git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@147 48953598-375a-da11-a14b-00016c27c3ee

lib/Maypole/Model/CDBI/Plain.pm [new file with mode: 0644]

diff --git a/lib/Maypole/Model/CDBI/Plain.pm b/lib/Maypole/Model/CDBI/Plain.pm
new file mode 100644 (file)
index 0000000..0bdee56
--- /dev/null
@@ -0,0 +1,34 @@
+package Maypole::Model::CDBI::Plain;
+use base 'Maypole::Model::CDBI';
+sub setup_database {
+    my ($self, $config, $namespace, $classes) = @_;
+    $config->{classes} = $classes;
+    $config->{table_to_class}  = { map { $_->table => $_ } @$classes };
+    $config->{tables} = [ keys %{$config->{table_to_class}} ];
+}
+
+sub class_of {
+    my ($self, $r, $table) = @_;
+    return $r->config->{table_to_class}->{$table};
+}
+
+1;
+
+=head1 NAME
+
+Maypole::Model::CDBI::Plain - Class::DBI model without ::Loader
+
+=head1 SYNOPSIS
+
+    package Foo;
+    use base 'Apache::DBI';
+    use Foo::SomeTable;
+    use Foo::Other::Table;
+
+    Foo->config->{model_class} = "Maypole::Model::CDBI::Plain";
+    Foo->setup([qw/ Foo::SomeTable Foo::Other::Table /]);
+
+=head1 DESCRIPTION
+
+This module allows you to use Maypole with previously set-up
+C<Class::DBI> classes.