X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole.pm;h=5837848df1c59e3ebeebec65aab5ef94dff1d744;hb=29550a30ca082a8f1f1d0cb1b4a92eb39bc3dd84;hp=2ba88c4286b538bcd5eae753656d5d6586b7ce06;hpb=425dd28a3e2ac3716d95e03ea3048307dcb25c08;p=maypole.git diff --git a/lib/Maypole.pm b/lib/Maypole.pm index 2ba88c4..5837848 100644 --- a/lib/Maypole.pm +++ b/lib/Maypole.pm @@ -12,7 +12,7 @@ use URI::QueryParam; use NEXT; use File::MMagic::XS qw(:compat); -our $VERSION = '2.11_pre3'; +our $VERSION = '2.11'; our $mmagic = File::MMagic::XS->new(); # proposed privacy conventions: @@ -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