]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Apache/MVC/Model/CDBI.pm
Swathes of documentation.
[maypole.git] / lib / Apache / MVC / Model / CDBI.pm
index 4d6339d1745b0201d4e9c6655051b79f26fe751e..8d75c30aec1883cb98d23e1af7345ee83780fc31 100644 (file)
@@ -7,15 +7,6 @@ use Class::DBI::AbstractSearch;
 use CGI::Untaint;
 use strict;
 
-sub description { "A poorly defined class" }
-
-sub column_names { my $class = shift; map { $_ => ucfirst $_ } $class->columns }
-
-sub get_objects {
-    my ($self, $r) = @_;
-    return $self->retrieve(shift @{$r->{args}});
-}
-
 sub related {
     my ($self, $r) = @_;
     # Has-many methods; XXX this is a hack
@@ -62,9 +53,11 @@ sub adopt {
 }
 
 sub search :Exported {
+    return shift->SUPER::search(@_) if caller eq "Class::DBI"; # oops
     my ($self, $r) = @_;
     my %fields = map {$_ => 1 } $self->columns;
     my $oper = "like"; # For now
+    use Carp; Carp::confess("Urgh") unless ref $r;
     my %params = %{$r->{params}};
     my %values = map { $_ => {$oper, $oper eq "like" ? "%".$params{$_}."%" 
                                                      :$params{$_} } }
@@ -75,5 +68,15 @@ sub search :Exported {
     $r->{template_args}{search} = 1;
 }
 
-
 1;
+
+=head1 NAME
+
+Apache::MVC::Model::CDBI - Model class based on Class::DBI
+
+=head1 DESCRIPTION
+
+This is a master model class which uses C<Class::DBI> to do all the hard
+work of fetching rows and representing them as objects; instead, it
+concentrates on the actions that can be performed in the URL:
+C<do_edit>, C<delete> and C<search>.