]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Maypole/Model/CDBI/Plain.pm
C3, inheritence changes and adding skeleton DFV model
[maypole.git] / lib / Maypole / Model / CDBI / Plain.pm
index 7a36f68034bbe3b6104489a0dc2f8c6db465b366..c95bead3babdd720fb2f76f1ac8096076f94c785 100644 (file)
@@ -1,4 +1,5 @@
 package Maypole::Model::CDBI::Plain;
+use Class::C3;
 use Maypole::Config;
 use base 'Maypole::Model::CDBI';
 use strict;
@@ -17,6 +18,18 @@ Maypole::Model::CDBI::Plain - Class::DBI model without ::Loader
     Foo->config->model("Maypole::Model::CDBI::Plain");
     Foo->setup([qw/ Foo::SomeTable Foo::Other::Table /]);
 
+    # untaint columns and provide custom actions for each class
+
+    Foo::SomeTable->untaint_columns(email => ['email'], printable => [qw/name description/]);
+
+    Foo::Other::Table->untaint_columns ( ... );
+
+    sub Foo::SomeTable::SomeAction : Exported {
+
+        . . .
+
+    }
+
 =head1 DESCRIPTION
 
 This module allows you to use Maypole with previously set-up
@@ -36,15 +49,10 @@ tables and set up the inheritance relationships as normal.
 
   This method loads the model classes for the application
 
-=head1 SEE ALSO
-
-L<Maypole::Model::Base>
-
-L<Maypole::Model::CDBI>
-
 =cut
 
 
+
 sub setup_database {
     my ( $self, $config, $namespace, $classes ) = @_;
     $config->{classes}        = $classes;
@@ -54,11 +62,39 @@ sub setup_database {
     $config->{tables}         = [ keys %{ $config->{table_to_class} } ];
 }
 
+=head2 class_of
+
+  returns class for given table
+
+=cut
+
 sub class_of {
     my ( $self, $r, $table ) = @_;
     return $r->config->{table_to_class}->{$table};
 }
 
+=head2 adopt
+
+This class method is passed the name of a model class that represensts a table
+and allows the master model class to do any set-up required.
+
+=cut
+
+sub adopt {
+    my ( $self, $child ) = @_;
+    if ( my $col = $child->stringify_column ) {
+        $child->columns( Stringify => $col );
+    }
+}
+
+=head1 SEE ALSO
+
+L<Maypole::Model::Base>
+
+L<Maypole::Model::CDBI>
+
+=cut
+
 
 1;