From fafd8d81987fbb130e02b89ed55c78a6cc34127a Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Mon, 14 Jun 2004 14:56:49 +0000 Subject: [PATCH] Has no docs yet, but still useful. git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@147 48953598-375a-da11-a14b-00016c27c3ee --- lib/Maypole/Model/CDBI/Plain.pm | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/Maypole/Model/CDBI/Plain.pm diff --git a/lib/Maypole/Model/CDBI/Plain.pm b/lib/Maypole/Model/CDBI/Plain.pm new file mode 100644 index 0000000..0bdee56 --- /dev/null +++ b/lib/Maypole/Model/CDBI/Plain.pm @@ -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 classes. -- 2.39.5