[Jifty-commit] r4547 - in jifty/trunk: lib/Jifty
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Tue Nov 27 20:40:31 EST 2007
Author: sartak
Date: Tue Nov 27 20:40:29 2007
New Revision: 4547
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Record.pm
Log:
r45691 at onn: sartak | 2007-11-27 20:40:06 -0500
Add an 'as_user' method and have 'as_superuser' use it
Modified: jifty/trunk/lib/Jifty/Record.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Record.pm (original)
+++ jifty/trunk/lib/Jifty/Record.pm Tue Nov 27 20:40:29 2007
@@ -521,6 +521,23 @@
$value;
}
+=head2 as_user CurrentUser
+
+Returns a copy of this object with the current_user set to the given
+current_user. This is a way to act on behalf of a particular user (perhaps the
+owner of the object)
+
+=cut
+
+sub as_user {
+ my $self = shift;
+ my $user = shift;
+
+ my $clone = $self->new( current_user => $user );
+ $clone->load( $self->id );
+ return $clone;
+}
+
=head2 as_superuser
Returns a copy of this object with the current_user set to the
@@ -531,10 +548,7 @@
sub as_superuser {
my $self = shift;
-
- my $clone = $self->new( current_user => $self->current_user->superuser );
- $clone->load( $self->id );
- return $clone;
+ return $self->as_user( $self->current_user->superuser );
}
=head2 delete PARAMHASH
More information about the Jifty-commit
mailing list