X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole.pm;h=5837848df1c59e3ebeebec65aab5ef94dff1d744;hb=29550a30ca082a8f1f1d0cb1b4a92eb39bc3dd84;hp=d14f517cddd56088a338a71b33e9f3f43057d101;hpb=922309d0f33d6cdb5e95263af2d8ff0c8de43898;p=maypole.git diff --git a/lib/Maypole.pm b/lib/Maypole.pm index d14f517..5837848 100644 --- a/lib/Maypole.pm +++ b/lib/Maypole.pm @@ -1146,6 +1146,24 @@ If the first item in C<$self-Eargs> can be Cd by the model class, it will be removed from C and the retrieved object will be added to the C list. See L for more information. + +=item object + +Alias to get/set the first/only model object. The object will be accessible +in the view templates. + +When used to set the object, will overwrite the request objects +with a single object. + +=cut + +sub object { + my ($r,$object) = @_; + $r->objects([$object]) if ($object); + return undef unless $r->objects(); + return $r->objects->[0]; +} + =item template_args $self->template_args->{foo} = 'bar'; @@ -1154,7 +1172,7 @@ Get/set a hash of template variables. =item stash -A place to put custom application data. Not used by Maypole itself. +A place to put custom application data. Not used by Maypole itself. =item template