X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole%2FModel%2FBase.pm;h=6e60aea7f9c3f4505b93263eaa31fcef4dc240d2;hb=5c199c0e9cd05a00bfc04d9688982979a41f3ee8;hp=d092e502dd33ae61866d3d43c80d7d32528cdcb1;hpb=e82766d6aab88a10e75b4669f44d2dbe7ff9d766;p=maypole.git diff --git a/lib/Maypole/Model/Base.pm b/lib/Maypole/Model/Base.pm index d092e50..6e60aea 100644 --- a/lib/Maypole/Model/Base.pm +++ b/lib/Maypole/Model/Base.pm @@ -9,12 +9,16 @@ sub edit :Exported { } sub process { my ($class, $r) = @_; my $method = $r->action; - $r->{template} ||= $method; # Authentication may have done this for us - $r->objects([ $class->retrieve(shift @{$r->{args}}) ]); - - # This allows the authentication mechanism to set the template - # without needing to define an action. - $class->$method($r) if $class->can($method); + return if $r->{template}; # Authentication has set this, we're done. + + $r->{template} = $method; + $r->objects([]); + my $obj = $class->retrieve( $r->{args}->[0] ); + if ($obj) { + $r->objects([ $obj ]); + shift @{$r->{args}}; + } + $class->$method($r, $obj, @{$r->{args}}); } sub display_columns { @@ -121,7 +125,7 @@ Return a hash mapping column names with human-readable equivalents. sub column_names { my $class = shift; map { my $col = $_; - $col =~ s/_+(\w)?/ \U\1/g; + $col =~ s/_+(\w)?/ \U$1/g; $_ => ucfirst $col } $class->columns } =head2 description