]> 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 83ce94ab31d51974bbdcf9c608c54b9a8d18b32c..5837848df1c59e3ebeebec65aab5ef94dff1d744 100644 (file)
@@ -12,7 +12,7 @@ use URI::QueryParam;
 use NEXT;
 use File::MMagic::XS qw(:compat);
 
-our $VERSION = '2.11_pre2';
+our $VERSION = '2.11';
 our $mmagic = File::MMagic::XS->new();
 
 # proposed privacy conventions:
@@ -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