Merge branch 'main' of git.arvados.org:arvados into 22202-delete-process-navigation
[arvados.git] / services / api / lib / arvados_model_updates.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 module ArvadosModelUpdates
6   # ArvadosModel checks this to decide whether it should update the
7   # 'modified_by_user_uuid' field.
8   def anonymous_updater
9     Thread.current[:anonymous_updater] || false
10   end
11
12   def leave_modified_by_user_alone
13     anonymous_updater_was = anonymous_updater
14     begin
15       Thread.current[:anonymous_updater] = true
16       yield
17     ensure
18       Thread.current[:anonymous_updater] = anonymous_updater_was
19     end
20   end
21
22   # ArvadosModel checks this to decide whether it should update the
23   # 'modified_at' field.
24   def timeless_updater
25     Thread.current[:timeless_updater] || false
26   end
27
28   def leave_modified_at_alone
29     timeless_updater_was = timeless_updater
30     begin
31       Thread.current[:timeless_updater] = true
32       yield
33     ensure
34       Thread.current[:timeless_updater] = timeless_updater_was
35     end
36   end
37
38 end