Merge branch '4015-collection-chooser-portable-data-hash'
[arvados.git] / services / api / lib / current_api_client.rb
index 6d85212eb96a5d1639e57d1453856999790f9de9..4c26010d2a4a3c0e6c38ae7911c2c9eb84eb822f 100644 (file)
@@ -100,18 +100,24 @@ module CurrentApiClient
 
   def act_as_system_user
     if block_given?
-      user_was = Thread.current[:user]
-      Thread.current[:user] = system_user
-      begin
+      act_as_user system_user do
         yield
-      ensure
-        Thread.current[:user] = user_was
       end
     else
       Thread.current[:user] = system_user
     end
   end
 
+  def act_as_user user
+    user_was = Thread.current[:user]
+    Thread.current[:user] = user
+    begin
+      yield
+    ensure
+      Thread.current[:user] = user_was
+    end
+  end
+
   def anonymous_group
     if not $anonymous_group
       act_as_system_user do