]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Maypole.pm
added object method, not added to templates yet
[maypole.git] / lib / Maypole.pm
index d14f517cddd56088a338a71b33e9f3f43057d101..5837848df1c59e3ebeebec65aab5ef94dff1d744 100644 (file)
@@ -1146,6 +1146,24 @@ If the first item in C<$self-E<gt>args> can be C<retrieve()>d by the model
 class, it will be removed from C<args> and the retrieved object will be added to
 the C<objects> list. See L<Maypole::Model> 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