From: Simon Cozens Date: Mon, 14 Jun 2004 14:56:49 +0000 (+0000) Subject: Has no docs yet, but still useful. X-Git-Tag: 2.10~215 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=fafd8d81987fbb130e02b89ed55c78a6cc34127a;p=maypole.git Has no docs yet, but still useful. git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@147 48953598-375a-da11-a14b-00016c27c3ee --- 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.