2018-08-03 13:22:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-07 04:11:41 -05:00
|
|
|
module BulkMemberAccessLoad
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
2021-12-06 22:12:22 -05:00
|
|
|
def merge_value_to_request_store(resource_klass, resource_id, value)
|
2022-03-14 14:07:46 -04:00
|
|
|
Gitlab::SafeRequestLoader.execute(resource_key: max_member_access_for_resource_key(resource_klass),
|
|
|
|
resource_ids: [resource_id],
|
|
|
|
default_value: Gitlab::Access::NO_ACCESS) do
|
2021-04-13 14:11:28 -04:00
|
|
|
{ resource_id => value }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-05-11 23:08:58 -04:00
|
|
|
def purge_resource_id_from_request_store(resource_klass, resource_id)
|
|
|
|
Gitlab::SafeRequestPurger.execute(resource_key: max_member_access_for_resource_key(resource_klass),
|
|
|
|
resource_ids: [resource_id])
|
|
|
|
end
|
|
|
|
|
2022-03-14 14:07:46 -04:00
|
|
|
def max_member_access_for_resource_key(klass)
|
|
|
|
"max_member_access_for_#{klass.name.underscore.pluralize}:#{self.class}:#{self.id}"
|
2021-04-13 14:11:28 -04:00
|
|
|
end
|
2017-12-07 04:11:41 -05:00
|
|
|
end
|
|
|
|
end
|